Announcement

Collapse
No announcement yet.

parsing metadata table to table concat, how?

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

  • parsing metadata table to table concat, how?

    Hi all
    Im trying to parse the entire table by concatenating with the "\r\n" delimiter and then showing to screen with the dialog.message action, but when I do this I get no error only a blank result (no data is shown to user), what or why I cant get the data from table to be shown to user?

    Code I used:
    PHP Code:
       tblMyData={}
        
        
    tblMyData[1] = {number="1"name="John"surname="nolte"}
        
    tblMyData[2] = {number="2"name="Mike"surname="smith"}
        
    tblMyData[3] = {number="3"name="Louise"surname="Brandon"}
        

        
    tablero Table.Concat(tblMyData"\r\n"1TABLE_ALL);
        
    Dialog.TimedMessage("hey"tablero2000MB_ICONINFORMATION); 

  • #2
    testing this, I get partially some result, but not the full table concatenated:
    PHP Code:
    Dialog.Message("hey!!""Nombre: "..tblMyData[3].name.."\r\nApellidos: "..tblMyData[3].surname2000MB_ICONINFORMATION); 

    Comment


    • #3
      You're trying to concatenate multiple values across an associative-array. Don't think that's even possible (at least not without writing some kind of function for it) and which is why you're getting nil returns.

      Instead, try restructuring the table - so that you can apply the Table.Concat function to each of its individual properties. And then you can just concatenate the outputted strings (together with the desired \r\n delimiter). Like this:
      Code:
      tblMyData = {};
      tblMyData.one = {"1", "John", "Nolte"}
      tblMyData.two = {"2", "Mike", "Smith"}
      tblMyData.three = {"3", "Louise", "Brandon"}
      
      strOne = Table.Concat(tblMyData.one, " ", 1, TABLE_ALL);
      strTwo = Table.Concat(tblMyData.two, " ", 1, TABLE_ALL);
      strThree = Table.Concat(tblMyData.three, " ", 1, TABLE_ALL);
      
      Dialog.Message("Notice", strOne.."\r\n"..strTwo.."\r\n"..strThree, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

      Or you could do away with the Table.Concat function altogether, by restructuring the table in a different way - so that its properties have their values expressed in linear fashion. And then just join each of the values via their index-number (together with \r\n\ delimiter). Like this:
      Code:
      tblMyData = {};    
      tblMyData.number = {"1","2","3"};
      tblMyData.name = {"John","Mike","Louise"};
      tblMyData.surname = {"Nolte","Smith","Brandon"};
      
      strOne = tblMyData.number[1].." "..tblMyData.name[1].." "..tblMyData.surname[1].."\r\n";
      strTwo = tblMyData.number[2].." "..tblMyData.name[2].." "..tblMyData.surname[2].."\r\n";
      strThree= tblMyData.number[3].." "..tblMyData.name[3].." "..tblMyData.surname[3].."\r\n";
      
      Dialog.Message("Notice", strOne..strTwo..strThree, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

      Or you could even take a different approach altogether, by storing the table values in an XML database. And then calling the XML.GetValue function to concatenate the outputted strings. Like in the attached example below.

      Attached Files

      Comment


      • #4
        Or if you want XML option without the external database,

        then just embed the XML as a string in Globals,
        like this:
        Attached Files

        Comment


        • #5
          Hey Bio!
          thanks for remembering there was another ways of making tables doh, the xml thing its interesting im reading the scripting guide for the xml part. I didn't notice there was xml functions. thanks again!

          Comment


          • #6
            Hey naxo,

            I know this is an old thread now, but was just looking over your request again. If u still wanted to express your table the same way you originally had it set up (ie. as a multidimensional-array), then you can actually access and concat the values like this:
            Code:
            [I][COLOR=#008000]-- Table expressed as Multidimensional Array[/COLOR][/I]
            
            tblMyData={};  
            tblMyData[1] = {number="1", name="John", surname="Nolte"};
            tblMyData[2] = {number="2", name="Mike", surname="Smith"};
            tblMyData[3] = {number="3", name="Louise", surname="Brandon"};
                
            [I][COLOR=#008000]-- Access and concat the values like this:[/COLOR][/I]
            
            for k,v in pairs (tblMyData) do
                 sNumber = tblMyData[k]["number"];
                 sName = tblMyData[k]["name"];
                 sSurname = tblMyData[k]["surname"];     
                 Debug.ShowWindow(true); 
                 Debug.Print(sNumber.." "..sName.." "..sSurname.."\r\n");[COLOR=#008000][/COLOR]
            end
            LMAO, answer was staring me in the face the whole time.
            Yet another, Homer Simpson moment.
            D'oh!

            Comment


            • #7
              Originally posted by BioHazard View Post
              Hey naxo,

              I know this is an old thread now, but was just looking over your request again. If u still wanted to express your table the same way you originally had it set up (ie. as a multidimensional-array), then you can actually access and concat the values like this:
              Code:
              [I][COLOR=#008000]-- Table expressed as Multidimensional Array[/COLOR][/I]
              
              tblMyData={};
              tblMyData[1] = {number="1", name="John", surname="Nolte"};
              tblMyData[2] = {number="2", name="Mike", surname="Smith"};
              tblMyData[3] = {number="3", name="Louise", surname="Brandon"};
              
              [I][COLOR=#008000]-- Access and concat the values like this:[/COLOR][/I]
              
              for k,v in pairs (tblMyData) do
              sNumber = tblMyData[k]["number"];
              sName = tblMyData[k]["name"];
              sSurname = tblMyData[k]["surname"];
              Debug.ShowWindow(true);
              Debug.Print(sNumber.." "..sName.." "..sSurname.."\r\n");
              end
              LMAO, answer was staring me in the face the whole time.
              Yet another, Homer Simpson moment.
              D'oh!
              i loled when I forgot that it was possible to do tables and getting data in this way, thanks dude!

              Comment

              Working...
              X