September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
32
Task/Loops-Foreach/BASIC/loops-foreach-6.basic
Normal file
32
Task/Loops-Foreach/BASIC/loops-foreach-6.basic
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
DEF AList:POINTER
|
||||
|
||||
AList=ListCreate()
|
||||
|
||||
'Add items to the list.
|
||||
DEF X:INT
|
||||
|
||||
FOR X=0 TO 10
|
||||
POINTER Temp=ListAdd(AList,NEW(INT,1))
|
||||
#<INT>temp=X
|
||||
'The hash ("#") dereferencing operator is unique to IWBASIC and Creative Basic, and
|
||||
'it is suitable for most basic pointer needs. IWBASIC also supports a "C style"
|
||||
'dereferencing operator: "*". And that will work here too.
|
||||
NEXT X
|
||||
|
||||
'A program compiled as console only does not need the commands to open and
|
||||
'close the console. However, it does not hurt to use them.
|
||||
OPENCONSOLE
|
||||
|
||||
'***Iterate the list with the "for each" loop***
|
||||
FOR Temp=EACH AList AS INT
|
||||
PRINT #Temp
|
||||
NEXT
|
||||
|
||||
PRINT
|
||||
|
||||
'A press any key to continue message is automatic in a program compiled as a console only
|
||||
program. I presume the compiler inserts the code.
|
||||
CLOSECONSOLE
|
||||
|
||||
'Because this is a console only program.
|
||||
END
|
||||
Loading…
Add table
Add a link
Reference in a new issue