Author Topic: REF for complex structures  (Read 15793 times)

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
REF for complex structures
« on: July 09, 2010, 04:36:54 PM »
The ScriptBasic REF statement allows for building complex variable structures in a more nature Basic way.

Code: [Select]
REF customer = addr
REF customer = phone
REF customer = bal

customer{"id"} = 1

addr{"name"} = "John Doe"
addr{"street"} = "Main St."
addr{"city"} = "Anytown"
addr{"state"} = "Unknown"

phone{"work"} = "800-555-1234"
phone{"home"} = "888-4444"

bal[30] = 100
bal[60] = 250
bal[90] = 0

PRINT customer{"id"},"\n"
PRINT customer{"name"},"\n"
PRINT customer{"street"},"\n"
PRINT customer{"city"},"\n"
PRINT customer{"state"},"\n"
PRINT customer{"work"},"\n"
PRINT customer{"home"},"\n"
PRINT customer[30],"\n"
PRINT customer[60],"\n"
PRINT customer[90],"\n"

C:\scriptbasic\test>reftest
1
John Doe
Main St.
Anytown
Unknown
800-555-1234
888-4444
100
250
0

REF

Array Mix Mode

Another example of accessing an associative array.

Code: [Select]
addr{"name"} = "John Doe"
addr{"street"} = "Main St."
addr{"city"} = "Anytown"
addr{"state"} = "Unknown"

FOR x = LBOUND(addr) TO UBOUND(addr)STEP 2
  PRINT addr[x],"=",addr{addr[x]},"\n"
NEXT x

C:\scriptbasic\test>aatest
name=John Doe
street=Main St.
city=Anytown
state=Unknown
« Last Edit: July 19, 2010, 12:13:42 AM by support »