PDA

View Full Version : attempting to compare a variable with the contents of an array



Lucian Cain
10-17-2006, 10:18 AM
I am attempting to compare the variable "ResultOS" with the contents of the array/table "PossiableOS.Valid".
any ideas?

ResultOS = System.GetOSName();
PossiableOS = {};
PossiableOS.Valid = {"Windows 98 SE", "Windows 2000", "Windows XP"};
PossiableOS.Invalid = {"Windows 95", "Windows 98", "Windows ME", "Windows NT 3", "Windows NT 4", "Windows Server 2003"};

if ResultOS == PossiableOS.Valid{} then

do this

else

do this

end

Desmond
10-17-2006, 10:52 AM
Hello,

Something like this may work for you:

Valid_OS = {"Windows 98 SE", "Windows 2000", "Windows XP"};
sSystemOS = System.GetOSName();

for nIndex, sOS in Valid_OS do
if (sSystemOS == sOS) then
bValidOS = true;
break;
end
end

if bValidOS then
-- The OS is valid
Dialog.Message("", "Valid OS");
else
-- The OS is invalid
Dialog.Message("", "Invalid OS");
end

Lucian Cain
10-17-2006, 03:12 PM
MGT wanted it to look for the reverse Desmond, thanks for your help. (GRUMBLE, GRUMBLE) I am still having a slight problem. Maybe it is just me. I do not understand how you went from the table PossiableOS.Invalid to boolean bPossiableOS.Invalid:

for nIndex, sOS in PossiableOS.Invalid do
if (sResultOS == sOS) then
bPossiableOS.Invalid = true;
break;
end
end
if bPossiableOS.Invalid then


--[This script is designed to first check the user's Operating System and display a dialog stating
--what it is. If the Operating System is "Windows 95", "Windows 98", "Windows ME", "Windows NT 3",
--"Windows NT 4", or "Windows Server 2003", then the Autorun will display a message stating that
--the AccuShade software will not install and close the autorun application.]--
--Get the system information
sResultOS = System.GetOSName();
ResultMEM = System.GetMemoryInfo(TotalRAM);
ResultVER = System.GetOSVersionInfo(BuildNumber);
PossiableOS = {"Windows 95", "Windows 98", "Windows ME", "Windows NT 3", "Windows NT 4", "Windows Server 2003", "Windows 98 SE", "Windows 2000", "Windows XP"};
PossiableOS.Valid = {"Windows 98 SE", "Windows 2000", "Windows XP"};
PossiableOS.Invalid = {"Windows 95", "Windows 98", "Windows ME", "Windows NT 3", "Windows NT 4", "Windows Server 2003"};

-- initialize variable
content=""

message="Information about your system"
strlen = String.Length(message);

for count = 1, strlen do
content = String.Left(message, count);
Label.SetText("Label3", content);
end

--Set the label texts by concatenating some text
--with the variables and then show them

Label.SetText("OSLabel", "Your Operating System is - "..sResultOS);
Label.SetText("RAMLabel", "Your Total RAM in Megabytes is - "..ResultMEM.TotalRAM);
Label.SetVisible("OSLabel", true);
Label.SetVisible("RAMLabel", true);


PossiableOS.Invalid = {"Windows 95", "Windows 98", "Windows ME", "Windows NT 3", "Windows NT 4", "Windows Server 2003"};
sResultOS = System.GetOSName();

for nIndex, sOS in PossiableOS.Invalid do
if (sResultOS == sOS) then
bPossiableOS.Invalid = true;
break;
end
end
if bPossiableOS.Invalid then
Label.SetText("Label5", "FAIL!")
Label.SetVisible("Label5",] true[/COLOR);
Label.SetText[COLOR="darkorchid"]("Label4", "PASS!")
Label.SetVisible("Label4", false);
Dialog.Message("WARNING!", "Your computer does not meet the minimum operating system specifications for the AccuShade Color Retrieval Software. There is no guarantee that the software will install sucessfully. Do you want to continue?",
MB_YESNO, MB_ICONEXCLAMATION, MB_DEFBUTTON10);
else
Label.SetText("Label5", "FAIL!")
Label.SetVisible("Label5", false);
Label.SetText("Label4", "PASS!")
Label.SetVisible("Label4", true);
end[/QUOTE][/QUOTE]

Desmond
10-17-2006, 03:19 PM
Hello,

bValidOS was set in this block of my example, and only if the user's OS was on your allowed list:

for nIndex, sOS in Valid_OS do
if (sSystemOS == sOS) then
bValidOS = true;
break;
end
end

I'm simply setting a variable to true so I can check it later.

Does that answer your question?

Lucian Cain
10-17-2006, 04:10 PM
yes, thanks