hBasic > hManual > Commands > Bundles

hBasic Manual
Changes to Bundles

Multiple Input
Access more than one key with one command
BUNDLE.CREATE
BUNDLE.PUT
BUNDLE.GET
Auto-Mode Matches keys with same named variables


Bundle Expressions
A new way to access bundle items

Multiple-Input

These are enhancements made to accept multiple input parameters with the same command.

BUNDLE.CREATE pointer_nvar {, pointer_nvar...}
creates one or more bundle(s) and puts the index in the pointer.
e.g
bundle.create b1, b2, b3, b4


BUNDLE.PUT pointer_nexp, key_sexp, <val_nexp | val_sexp> {, key, val...}
puts one or more objects in a bundle.
e.g
bundle.put mybundle_nexp,  "Key1", 99  "Key2","RED"  "Key3","Balloons"


BUNDLE.GET pointer_nexp, key_sexp, <val_nvar>|<val_svar> {, key, val...}
gets one or more objects from a bundle.
e.g
bundle.get mybundle,  "Key1", k1 ,  "Key2", k2$

'Auto' Mode

This enhancement made to get or put variables with the same named tag as a convenience.
For 'auto' mode, you only have to specify the variable (the tag is matched with the variable).

'auto' mode starts with a ' { ', followed by a list of comma separated variable names.
 and ends with a ' } '.

Variables must be numeric or strings. They cannot be arrays, array cells, literal numbers nor literal strings or you will get a syntax error.

The matching tags will be lower case with no spaces.    (Basic will always lower case all variable names)
The matching tags which are strings will also have the ending ' $ '.
 e.g'

Normal Mode
BUNDLE.PUT mybundle, "v1", v1

Multii-Mode
BUNDLE.PUT mybundle, "v1", v1,  "v2", v2,  "v3", v3

Auto Mode
BUNDLE.PUT mybundle, { v1, v2$, v3 }
Puts into the bundle using tags "v1", "v2$", "v3"  with content from variables v1, v2$, v3

BUNDLE.GET mybundle, { v1, v2$, v3 }
Gets content from bundle using tags "v1","v2$","v3" into variables v1, v2$, v3

Mixed Mode
'auto' mode can also be mixed with 'multi' mode;
BUNDLE.PUT mybundle, "mytag0", v0,  { v1, v2$, v3 },  "mytag1", 101