Path: news.cs.au.dk!not-for-mail From: Flemming Gram Christensen Newsgroups: comp.lang.beta Subject: Re: More newbie questions ... Date: 30 May 2000 16:04:11 +0200 Organization: University of Aarhus, Department of Computer Science (DAIMI) Lines: 108 Message-ID: References: <20000530105522.17371.qmail@noatun.mjolner.dk> <3933D308.6DFBD114@skynet.be> NNTP-Posting-Host: odin.mjolner.dk X-Trace: xinwen.cs.au.dk 959695456 17395365 255.255.255.255 (30 May 2000 14:04:16 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 30 May 2000 14:04:16 GMT X-Newsreader: Gnus v5.7/Emacs 20.4 Xref: news.cs.au.dk comp.lang.beta:12366 Atle writes: > Arne Hueggenberg wrote: > > > loops are not part of the language, but there are > > some convenience patterns implementing loops in the libraries. > > I did RTFM :-) > In the beginning, I didn't know exactly where the real documentation was, but now I've found it. > To jump-start me here, could you give me a couple of examples? (please?) > I will express in a sort of 'pseudocode' what I want to do: > > myList ml = ["atle", "beta", "compiler", "debug", "error", "free", "group" ] > > foreach X in ml do > print X > endforeach > > for i := 1 to ml.length do > print ml[i] ; subscripting > endfor > > and one like this: > > struct s { > char name[25]; > char addr[25]; > char tlf[25]; > }; > > struct s ss; > > print ss; > > That would help a lot! Here is a little program performing the above: ORIGIN '~beta/basiclib/betaenv'; INCLUDE '~beta/basiclib/formatio'; --PROGRAM: descriptor-- (# r:[8]^text; singleText:^text; (* struct s { char name[25]; char addr[25]; char tlf[25]; }; *) (* I prefer Texts and not char arrays, this is not C! *) Person: (# name,addr,phone:^text; print: (# do 'Name: '->puttext; name[]->putline; 'Addr: '->puttext; addr[]->putline; 'Phone: '->puttext; phone[]->putline; #); #); Atle:^Person; (* dynamic reference to Person *); do (* build a repetition (array) of text objects *) 'atle' -> r[1][]; 'beta' -> r[2][]; 'compiler'-> r[3][]; 'debug' -> r[4][]; 'error' -> r[5][]; 'free' -> r[6][]; 'group' -> r[7][]; (for i:r.range (* range = 8 *) repeat r[i][]->putline; for); (for i:r.range (* range = 8 *) repeat r[i][]->singleText[]; singleText[]->putline; for); (* Instantiate (allocate) Person object *) &Person[]->Atle[]; 'Atle R.' -> Atle.name[]; 'Norway' -> Atle.addr[]; '12343241'->Atle.phone[]; Atle.print; #) Please ask questions. More advanded output are also available. Look after putformat. Regards > > Thanks, Atle -- /Flemming Gram Christensen ------------------------------------------------------------------------ Mjolner Informatics ApS Phone: +45 86 20 20 00 Science Park Aarhus Fax: +45 86 20 12 22 Gustav Wieds Vej 10 DK-8000 Aarhus C Denmark E-mail: gram@mjolner.dk ------------------------------------------------------------------------