Redimension

From Br Wiki
Jump to: navigation, search

The Dim statement is used to set the dimensions of a variable or array.

Mat can be used to redimension an array, as seen in the following example of reading a file into a Grid:

00110     dim Firstname$(1)*30,Lastname$(1)*30,Address$(1)*30,City$(1)*15,State$(1)*2,Zipcodes$(1)*7
00130     open #1: "name=orders.INT,kfname=lastfirst.int, recl=118,kps=31/1,kln=30/30,USE", internal, outin, keyed
00140  !
00150     mat Firstname$(0)
00160     mat Lastname$(0)
00170     mat Address$(0)
00180     mat City$(0)
00190     mat State$(0)
00200     mat Zipcodes$(0)
00270  !
00280  READTHENEXTONE: ! Ok
00290     read #1, using RECFORM: Mat Answers$,Shipping$,Mat Ordered eof DONEREADING
00300  RECFORM: form C 30,C 30,C 30,C 15,C 2,C 7
00310  !
00320     let Newsize=Udim(Firstname$)+1
00330  !
00340     mat Firstname$(Newsize)
00350     mat Lastname$(Newsize)
00360     mat Address$(Newsize)
00370     mat City$(Newsize)
00380     mat State$(Newsize)
00390     mat Zipcodes$(Newsize)
00450  !
00460     let Firstname$(Newsize)=Answers$(1)
00470     let Lastname$(Newsize)=Answers$(2)
00480     let Address$(Newsize)=Answers$(3)
00490     let City$(Newsize)=Answers$(4)
00500     let State$(Newsize)=Answers$(5)
00510     let Zipcodes$(Newsize)=Answers$(6)
00570  !
00580     goto READTHENEXTONE
00590  !
00600  DONEREADING: ! We're done reading, go to the next part, print them on the grid

Udim can also be used to the redimension an array of an unknown size, demonstrated in line 320 above.


See also: