Announcement

Collapse
No announcement yet.

What is the analysis of a string?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • What is the analysis of a string?

    I have a string like this:
    token = | Hello | Computer | Herrin | Ulrich | Startup
    How can I turn it into a table so that:
    Code:
    token = | Hello | Computer | Herrin | Ulrich | Startup
    token[3]
    Show me, Herrin?

  • #2
    PHP Code:
    Global:
    function 
    Table.ItemDataFromString(tInputTablesSubTableString
    return 
    tInputTable[sSubTableString] or nil;
    end 

    PHP Code:
    Button OnClick:
    tTable = {};
    tTable[1] = {};
    tTable[1].One "Hello";
    tTable[1].Two "Computer";
    tTable[1].Three "Herrin";
    tTable[1].Four "Ulrich";
    tTable[1].Five"Startup"

    Data Table.ItemDataFromString(tTable[1], "Three");
    Dialog.Message("MyTable"Data); 

    Comment


    • #3
      Thank you, but what should I do if I do not know that the last member is a few sticks ?!

      Comment


      • #4
        Code:
        token = "| Hello | Computer | Herrin | Ulrich | Startup"
        
        tokenTbl = {}
        
        for S in string.gmatch (token, "(.-)|") do
        if S ~= "" then
        table.insert(tokenTbl, S);
        end
        end
        
        Dialog.Message("Notice", tokenTbl[3]);

        Comment


        • #5
          Originally posted by startup View Post
          Code:
          token = "| Hello | Computer | Herrin | Ulrich | Startup"
          
          tokenTbl = {}
          
          for S in string.gmatch (token, "(.-)|") do
          if S ~= "" then
          table.insert(tokenTbl, S);
          end
          end
          
          Dialog.Message("Notice", tokenTbl[3]);
          This is exactly what I wanted ...
          What gmatch in code?

          Comment


          • #6
            that was a function from the "mother LUA"

            Comment


            • #7
              table

              Table.apz

              Comment

              Working...
              X