Quantcast
Channel:
Viewing all articles
Browse latest Browse all 44712

Forum Post: RE: Get type of the list

$
0
0

If you know that list is going to populated you could simply check TypeOf(a[1]). That's not the best choice since it will fail on an empty list or if "a" isn't a list. This code should do the trick:

[-] testcase aaa() appstate none
   [ ]
   [ ]
   [ ] LIST of STRING a = {"aaa", "bbb"}
   [ ] INTEGER b = 1
   [ ]
   [ ] print(SuperTypeOf(a))
   [ ] print(SuperTypeOf(b))
   [ ]
[ ]
[-] STRING SuperTypeOf(ANYTYPE theVariable)
   [ ]
   [ ] STRING theType = [STRING]TypeOf(theVariable)
   [ ]
   [ ] // Convert to lower case for ease of use with StrPos()
   [ ] theType = lower(theType)
   [ ]
   [ ] // Check if it's a list
   [-] if(StrPos("list of", theType) > 0)
      [ ]
      [ ] // remove the part that says "list of " so you are left with the base type
      [ ] theType = StrTran(theType, "list of ", "")
      [ ]
      [ ] return(theType)
      [ ]
   [-] else
      [ ] // it's not a list so just return the type
      [ ] return(theType)
   [ ]


Viewing all articles
Browse latest Browse all 44712

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>