I use a few batch files on a slow computer and needed a wait program so I decided I'd just make one. I used the CLX.h because of the features it offers (like the vcl)
My problem/question is, the program works perfectly, but compiled with no external dependencies its 369k and once loaded into memory takes up 1,324k. I'd like to move away from the CLX to save the resources.
Heres the code:
I'm not the greatest programmer but I'm always trying to learn new ways to do things.
I've replaced the clx.h with windows.h
But now AnsiString is no longer valid nor is string.
(this time I'm trying to use VC++ 6 instead of Builder6)
I don't know of any way to convert the char input from argv to an unsigned long, or if that input is even valid anymore.
Please post your comments on this.
Always appreciated!
-Ruggie
My problem/question is, the program works perfectly, but compiled with no external dependencies its 369k and once loaded into memory takes up 1,324k. I'd like to move away from the CLX to save the resources.
Heres the code:
Code:
//---------------------------------------------------------------------------
#include <clx.h>
#include <iostream.h>
#pragma hdrstop
//---------------------------------------------------------------------------
#define RETURN_SUCCESS 0
#define RETURN_ERROR 1
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
if (argc == 1) // No arguments passed.
{
cout << endl;
cout << "Usage:" << endl;
cout << "wait.exe <SecondsToWait>" << endl;
cout << endl;
cout << "Example:" << endl;
cout << "wait.exe 30" << endl;
cout << "(Waits for 30 seconds, then exits)" << endl;
cout << endl << endl;
cout << "Returns 0 on success, 1 on fail." << endl;
return RETURN_ERROR;
}
else if (argc == 2) // Exactly 1 argument passed
{
try
{
// Process input
AnsiString as_SleepTime;
as_SleepTime = AnsiString(argv[1]);
unsigned long ul_SleepTime;
ul_SleepTime = as_SleepTime.ToInt();
ul_SleepTime = ul_SleepTime * 1000;
// Post msg
cout << "Waiting for " << argv[1] << " seconds." << endl;
cout << "Use CTRL+C to skip." << endl;
// Sleep
Sleep(ul_SleepTime);
return RETURN_SUCCESS;
}
catch (...) // Argument passed was not a number
{
cout << "ERROR!" << endl;
cout << "Was not able to convert input into an integer." << endl;
return RETURN_ERROR;
}
}
else // More then one argument passed.
{
cout << "ERROR! Improper usage!" << endl;
cout << "Usage:" << endl;
cout << "wait.exe <SecondsToWait>" << endl;
return RETURN_ERROR;
}
}
//---------------------------------------------------------------------------
I'm not the greatest programmer but I'm always trying to learn new ways to do things.
I've replaced the clx.h with windows.h
But now AnsiString is no longer valid nor is string.
(this time I'm trying to use VC++ 6 instead of Builder6)
I don't know of any way to convert the char input from argv to an unsigned long, or if that input is even valid anymore.
Please post your comments on this.
Always appreciated!
-Ruggie