Im writing a program that generates random number's from a certain point, my program works allright if the user enters a positive number but if the user enters a negative number if starts from the wrong point ( the number is changed into a positive one) what should i do?
Code:
LRESULT CALLBACK ProbeProc(HWND hwnd,UINT message,WPARAM wParam,
LPARAM lParam)
{
switch(message)
{
case WM_CLOSE:
EndDialog(hwnd,false);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDCANCEL:
MessageBox(NULL," AutoProbe 1.0 Copyright 2004\n Rebel Collective.\n Version Imformation : 1.0","About AutoProbe 1.0",MB_OKCANCEL);
break;
case IDOK:
int amountGen = 0;
amountGen = GetDlgItemInt(hwnd,IDC_EDIT1,NULL,NULL);
if (amountGen <= 0) // check to see if the number of cords to generate is above 0
// if it isent give the user a warning
{
MessageBox(NULL,"Please enter a number above 0","Runtime Error",MB_OKCANCEL);
}
else
{
int xCord,yCord,zCord;
xCord = GetDlgItemInt(hwnd,IDC_EDIT3,NULL,NULL);
yCord = GetDlgItemInt(hwnd,IDC_EDIT4,NULL,NULL);
zCord = GetDlgItemInt(hwnd,IDC_EDIT5,NULL,NULL);
for (int i=0; i<amountGen; i++)
{
int temxCord = xCord;
int temyCord = yCord;
int temzCord = zCord;
ofstream FILE("Data.txt", ios::app);
temxCord = temxCord + 100;
FILE << temxCord <<" " << temyCord <<" "<< temzCord <<endl;
temxCord = xCord;
temyCord = temyCord + 100;
FILE << temxCord <<" "<< temyCord <<" "<< temzCord <<endl;
temyCord = yCord;
temzCord = temzCord + 100;
FILE << temxCord <<" "<< temyCord <<" "<< temzCord <<endl;
temzCord = zCord;
xCord = xCord + 100;
yCord = yCord + 100;
zCord = zCord + 100;
}
}
break; // IDOK
}
break;
}
return false;
}