string / table compare

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • gabrielfenwich
    Forum Member
    • Dec 2004
    • 34

    string / table compare

    Hi all,
    I want to do a program update based on the program version found
    I've worked out the first bit so I can get the file version... all good
    I'm trying to compare a string to the contents of a table
    so that I do something different depending on what line of the table matched

    -- check the registry to see if it's installed and then fiind out where.
    exists = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "\\SOFTWARE\\Gabby");
    path = Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Gabby", "InstallPath", true);

    -- get version info
    version_info = File.GetVersionInfo( path .. "\\Gabby.exe");
    fv = version_info.FileVersion;
    fd = version_info.FileDescription
    pv = version_info.ProductVersion;

    -- show the user what version's installed so that they can manually update
    Paragraph.SetText("Paragraph1", fd.. fv.." is currently installed. Please click the appropriate version item to proceed");

    -- what I want to do is something like this

    -- this is the contents of table 1
    Gabby.exe 0.0.0.1
    Gabby.exe 0.0.0.2
    Gabby.exe 0.0.0.3
    Gabby.exe 0.0.0.4

    -- i want to search the table to find the matching entry and then do something depending on the result

    if fd.. fv.. = (table row 1) then
    File.Run("AutoPlay\\Docs\\update0001.exe", "", "", SW_SHOWNORMAL, false);
    else

    if fd.. fv.. = (table row 2) then
    File.Run("AutoPlay\\Docs\\update0002.exe", "", "", SW_SHOWNORMAL, false);
    else

    etc..

    -- but i can't see how to do it with only the 4 table commands listed in the help.

    Does anyone have any suggestions
    Gabby
  • csd214
    Forum Member
    • Oct 2001
    • 939

    #2
    I think your trouble is this line:
    if fd.. fv.. = (table row 2) then

    It doesn't matter whether you use fd.. fv or fd..fv or fd .. fv.

    You should enter a space between fd and fv in this way:
    if fd.." "..fv.. = (table row 2) then

    Example:

    Code:
    table1 = {};
    table1[1] = "Gabby.exe 0.0.0.1"
    table1[2] = "Gabby.exe 0.0.0.2"
    table1[3] = "Gabby.exe 0.0.0.3"
    table1[4] = "Gabby.exe 0.0.0.4"
    
    fd = "Gabby.exe"
    fv = "0.0.0.2"
    sVersion = "Not found";
    
    for index, data in table1 do
    	if fd.." "..fv == data then
    		sVersion = data;
    		break;
    	end
    end
    Dialog.Message("Result", "Your version: "..sVersion);

    Comment

    • gabrielfenwich
      Forum Member
      • Dec 2004
      • 34

      #3
      Thankyou..
      and thanks to all the other great ppl on the forums.
      Without the forums I'd be lost.
      I'm used to the engineering field where just about everything has at least 4 sets of long winded instructions ( none of which are usually right but it gives you something to go off).

      So between the help file, the scripting guide and the forums I'm learning more and doing more then I thought possoble.. It's great.

      A big well done to the Indigorose Team

      Gabby

      Comment

      • Corey
        Indigo Rose Staff Alumni
        • Aug 2002
        • 9745

        #4
        Thanks for the kind words about the forum Gabby. Once you get used to using tables (arrays) you'll love them. FYI There's a free video which explains AutoPlay Media Studio tables at http://www.speedytraining.com which might be worth checking out too, it's on the "CD 3" page...

        Comment

        • csd214
          Forum Member
          • Oct 2001
          • 939

          #5
          Glad to hear, Gabby.

          It's a perfect circle: Quality Products – High class help docs and training stuff – Incredible support – The forum of innovation and inspiration.

          I have learned a lot from this forum. The learning process never stops (and thanks for that…). I feel I have a debt to pay; the "pay back" is pleasuring!

          Corey reveals my secret; how did I get familiar with tables? Yes, the Speedy Training CDs are great.

          Comment

          • Intrigued
            Indigo Rose Customer
            • Dec 2003
            • 6138

            #6
            It's refreshing for sure to work as a team... on a global scale.

            If it takes programming together to make a better world... I say lets go for it.

            One project at a time.

            :yes
            Intrigued

            Comment

            Working...
            X