Author Topic: Script BASIC Arrays  (Read 35611 times)

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Script BASIC Arrays
« on: November 02, 2017, 02:58:53 PM »
One of my most favorite features of Script BASIC is its array (matrix) functionality. You don't have to define or dimension anything and there are no practical limits on indices. (associative, indexed or a combination of both)

Code: Script BASIC
  1. ' Test  Associative Array by Index
  2.  
  3. obj{"Name"}{"Value"} = undef
  4. obj{"Name"}{"Product"} = "ALL"
  5. obj{"Name"}{"Required"} = TRUE
  6. obj{"ID"}{"Value"} = undef
  7. obj{"ID"}{"Product"} = "SOME"
  8. obj{"ID"}{"Required"} = FALSE
  9.  
  10. this{"Extension"}{"Value"} = "Default"
  11. this{"Extension"}{"Product"} = "FEW"
  12. this{"Extension"}{"Required"} = "MAYBE"
  13.  
  14. obj{"Version"} = this{"Extension"}
  15.  
  16. FOR o = 0 TO UBOUND(obj) STEP 2
  17.   PRINT obj[o],"\n"
  18.   FOR p = 0 TO UBOUND(obj[o + 1]) STEP 2
  19.     PRINT obj[o + 1, p]," - ",obj[o + 1, p + 1],"\n"
  20.   NEXT
  21. NEXT
  22.  
  23. PRINT "-------------------------------","\n"
  24.  
  25. PRINT obj[0],"\n"
  26. PRINT obj[1,0]," - ",obj[1,1],"\n"
  27. PRINT obj[1,2]," - ",obj[1,3],"\n"
  28. PRINT obj[1,4]," - ",obj[1,5],"\n"
  29. PRINT obj[2],"\n"
  30. PRINT obj[3,0]," - ",obj[3,1],"\n"
  31. PRINT obj[3,2]," - ",obj[3,3],"\n"
  32. PRINT obj[3,4]," - ",obj[3,5],"\n"
  33. PRINT obj[4],"\n"
  34. PRINT obj[5,0]," - ",obj[5,1],"\n"
  35. PRINT obj[5,2]," - ",obj[5,3],"\n"
  36. PRINT obj[5,4]," - ",obj[5,5],"\n"
  37.  
  38.  
  39. PRINT "-------------------------------","\n"
  40.  
  41. PRINT obj[2],"\n"
  42. FOR z = 0 TO UBOUND(obj{"ID"}) STEP 2
  43.   PRINT obj{"ID"}[z]," - ",obj{"ID"}[z + 1],"\n"
  44. NEXT
  45.  


Name
Value - undef
Product - ALL
Required - -1
ID
Value - undef
Product - SOME
Required - 0
Version
Value - Default
Product - FEW
Required - MAYBE
-------------------------------
Name
Value - undef
Product - ALL
Required - -1
ID
Value - undef
Product - SOME
Required - 0
Version
Value - Default
Product - FEW
Required - MAYBE
-------------------------------
ID
Value - undef
Product - SOME
Required - 0

« Last Edit: November 02, 2017, 03:01:39 PM by support »