|
||
|
|
#2 (permalink) |
|
Forum Expert
Join Date: Nov 2003
Location: Illinois, USA
Age: 21
Posts: 2,911
|
eeek first of all, those tags dont fit at all, maybe just make them one tag "first runtime" or "first execution"... anyways
Depending on the user's permissions you could either a) write to the registry and check if a key has been written or not or b)write a small file in the same directory as the application.
__________________
Useful links (Use them or die in a fire!!!): Ultimate Little Guide, C# Tutorials & Docs, RunUO Basic Scripts, Run UO How to..., Configure server for connections, Scripting for Dummies, Common Problem Solutions, FAQ Forum, RunUO Wiki, Basic Generics, Xml Tutorial |
|
|
|
|
|
#3 (permalink) |
|
Newbie
Join Date: Jan 2006
Posts: 34
|
That's what I've been trying to do... Here's what I've been trying to do (keep in mind that these are cuts from the program, not the entire program):
Code:
// Cut 1: Prototypes...
int Config (int check, int firstrun);
int Config2 (string line, int firstrun);
// Cut 2: main()...
int main()
{
int check;
int firstrun;
Config(check,firstrun);
if (check == 1 && firstrun == 1)
{
ofstream config;
config.open ("firstruncheck.sece", ios::out);
config << "false";
config.close();
ofstream autoexec;
autoexec.open ("autoexec.cfg", ios::out | ios::app);
autoexec << "// SECE execution commands...\n";
autoexec.close();
}
else
{
cout << "The program seems to have returned an error...\n";
}
// Cut 3: Functions...
int Config (int check, int firstrun)
{
string line;
ifstream config ("firstruncheck.sece");
if (config.is_open())
{
while (!config.eof())
{
getline (config,line);
Config2(line,firstrun);
continue;
}
check = 1;
return (check,firstrun);
}
else
{
cout << "The program has returned an error...\n";
cout << "Please try again...\n";
main();
}
}
// Function 2...
int Config2 (string line, int firstrun)
{
if (line == "true")
{
firstrun = 1;
}
return (firstrun);
}
|
|
|
|
|
|
#5 (permalink) |
|
Forum Novice
Join Date: Jul 2004
Location: Switzerland
Age: 25
Posts: 234
|
This cannot succeed...
Code:
// Cut 1: Prototypes...
int Config (int check, int firstrun); Param passed as VALUE. References are denotated with &
int Config2 (string line, int firstrun);
// Cut 2: main()...
int main()
{
int check;
int firstrun;
Config(check,firstrun); params passed as if they were references.
//(check and firstrun now still uninitialized, containing random data)
if (check == 1 && firstrun == 1)//both variables contain random data, The result of this check is random as well
{
ofstream config;
config.open ("firstruncheck.sece", ios::out);
config << "false";
config.close();
ofstream autoexec;
autoexec.open ("autoexec.cfg", ios::out | ios::app);
autoexec << "// SECE execution commands...\n";
autoexec.close();
// needs a return code. 'return 0'
}
else
{
cout << "The program seems to have returned an error...\n";
// needs a return code. 'return 1'
}
// Main lacks an ending } here. Keeps code seperated as obviously intended, without subfunctions.
// Cut 3: Functions...
int Config (int check, int firstrun)
{
string line;
ifstream config ("firstruncheck.sece");
if (config.is_open())
{
while (!config.eof())
{
getline (config,line);
Config2(line,firstrun);// calling this has no effect. firstrun is passed as value, not as reference. try a statement like 'firstrun = Config2(line);' after modifying the code
continue;//not needed at the end of a loop
}
check = 1; // check is a local parameter, not a reference. initialize will affect nothing here.
return (check,firstrun);// not valid. return code must be an int type. like 0
}
else
{
cout << "The program has returned an error...\n";
cout << "Please try again...\n";
main();//restarts main(), evokes an endless loop of calls. Should be 'return 1'
}
}
// Function 2...
int Config2 (string line, int firstrun)
{
if (line == "true")
{
firstrun = 1;
}
return (firstrun);
}
I didnt check the functions for validity, there can be more errors. Good Luck ![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|