attempting to compare a variable with the contents of an array

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Lucian Cain
    Indigo Rose Customer
    • Jul 2006
    • 12

    attempting to compare a variable with the contents of an array

    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
    Indigo Rose Staff Member
    • Jul 2003
    • 710

    #2
    Hello,

    Something like this may work for you:
    Code:
    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

    Comment

    • Lucian Cain
      Indigo Rose Customer
      • Jul 2006
      • 12

      #3
      sorry in advance for the lengthy post...

      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",] [COLOR="Blue"]true[/COLOR);
      Label.SetText("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]

      Comment

      • Desmond
        Indigo Rose Staff Member
        • Jul 2003
        • 710

        #4
        Hello,

        bValidOS was set in this block of my example, and only if the user's OS was on your allowed list:
        Code:
        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?

        Comment

        • Lucian Cain
          Indigo Rose Customer
          • Jul 2006
          • 12

          #5
          yes, thanks

          Comment

          Working...
          X