Author Topic: Script BASIC Arrays  (Read 29674 times)

Support

  • Administrator
  • *****
  • Posts: 1
    • View Profile
Script BASIC Arrays
« on: November 02, 2017, 09: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)

' Test  Associative Array by Index

obj{"Name"}{"Value"} = undef
obj{"Name"}{"Product"} = "ALL"
obj{"Name"}{"Required"} = TRUE
obj{"ID"}{"Value"} = undef
obj{"ID"}{"Product"} = "SOME"
obj{"ID"}{"Required"} = FALSE

this{"Extension"}{"Value"} = "Default"
this{"Extension"}{"Product"} = "FEW"
this{"Extension"}{"Required"} = "MAYBE"

obj{"Version"} = this{"Extension"}

FOR o = 0 TO UBOUND(obj) STEP 2
  PRINT obj[o],"\n"
  FOR p = 0 TO UBOUND(obj[o + 1]) STEP 2
    PRINT obj[o + 1, p]," - ",obj[o + 1, p + 1],"\n"
  NEXT
NEXT

PRINT "-------------------------------","\n"

PRINT obj[0],"\n"
PRINT obj[1,0]," - ",obj[1,1],"\n"
PRINT obj[1,2]," - ",obj[1,3],"\n"
PRINT obj[1,4]," - ",obj[1,5],"\n"
PRINT obj[2],"\n"
PRINT obj[3,0]," - ",obj[3,1],"\n"
PRINT obj[3,2]," - ",obj[3,3],"\n"
PRINT obj[3,4]," - ",obj[3,5],"\n"
PRINT obj[4],"\n"
PRINT obj[5,0]," - ",obj[5,1],"\n"
PRINT obj[5,2]," - ",obj[5,3],"\n"
PRINT obj[5,4]," - ",obj[5,5],"\n"


PRINT "-------------------------------","\n"

PRINT obj[2],"\n"
FOR z = 0 TO UBOUND(obj{"ID"}) STEP 2
  PRINT obj{"ID"}[z]," - ",obj{"ID"}[z + 1],"\n"
NEXT
 

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, 10:01:39 pm by support »