7 Replies Latest reply: Oct 20, 2014 4:33 AM by Friedrich Hofmann RSS

    Tablename()?

    Friedrich Hofmann

      Hi,

       

      can anybody please explain to me the use of this function which is not detailed in the help_file?

      I have been proposed this as part of a code to clean up all existing tables (but for specific ones), but I guess it can also be used in combination with the TRACE command to see which tables exist at a given point, e.g. within a subroutine, each time it is called.

       

      From the help_file I know that it takes the table_number as a parameter - but what is the table_number?

       

      Thanks a lot!

       

      Best regards,

       

      DataNibbler

        • Re: Tablename()?
          Tresesco B

          Table_number is the sequence number of loaded tables. The first loaded table has number 0, second one 1, .. 2, .... That means if you have loaded tables like :

          Tab1:

          Load

                    * From <>;

          Tab2:

          Load

                    * From <>;

           

          TableName(0) -> returns 'Tab1'

          TableName(1) -> returns 'Tab2'

           

          Hoep this helps.

            • Re: Tablename()?
              Friedrich Hofmann

              Hi tresesco,

               

              it does help. I supposed so much, but having it from someone who knows is better.

              Unfortunately, in the context I want to use this currently, I don't know the sequence, so that doesn't really help me - but it is good to know. I might be able to use this lateron.

              Thanks!

              Best regards,

               

              DataNibbler

                • Re: Tablename()?
                  Tresesco B

                  DataNibbler wrote:

                  I have been proposed this as part of a code to clean up all existing tables (but for specific ones),...

                  So you know the names of the tables before hand, if so, would not simply using Drop Tables help? Am I missing something?

                    • Re: Tablename()?
                      Friedrich Hofmann

                      Hi tresesco,

                       

                      the context was a subroutine and for some reason some fragmented tables were being created in the individual iterations, but I didn't know for sure where and why - and I cannot write a DROP statement for a fragment anyway beecause of the "-" ...

                      Of course, whenever you know the names of interim tables, dropping them right away with this statement is the more elegant solution.

                      Also, I am having trouble with the TRACE: I can set a variable to TableName(0) and then write a TRACE statement with the value of that - but somehow writing TRACE TableName(0) or something like that won't work.

                      Can you help me there?

                      Thanks a lot!

                • Re: Tablename()?
                  Massimo Grossi

                  for tab=1 to 3

                   

                    trace **********;

                   

                    Table$(tab):

                    load

                    rand() * 100  as [Field Table$(tab)]

                    AutoGenerate 10;

                   

                    // trace with tablename and tablenumber

                    for i=0 to NoOfTables()-1

                     let t=TableName(i);

                     let n=TableNumber(TableName(i));

                     trace TableName is $(t);

                     trace TableNumber is $(n);

                    next;

                   

                  next;