Loops/Foreach: Difference between revisions
Content deleted Content added
Line 683: | Line 683: | ||
DEF AList:POINTER |
DEF AList:POINTER |
||
⚫ | |||
AList=ListCreate() |
AList=ListCreate() |
||
'add items to the list |
'add items to the list |
||
⚫ | |||
FOR X=0 TO 10 |
FOR X=0 TO 10 |
||
POINTER Temp=ListAdd(AList,NEW(INT,1)) |
POINTER Temp=ListAdd(AList,NEW(INT,1)) |
||
#<INT> |
#<INT>temp=X |
||
'The hash |
'The hash ("#") dereferencing operator is unique to IWBASIC and Creative Basic, and |
||
'pointer needs. IWBASIC also supports a "C style" |
'it is suitable for most basic pointer needs. IWBASIC also supports a "C style" |
||
'dereferencing operator: "*". And that will work here too. |
|||
NEXT X |
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 |
|||
⚫ | |||
FOR Temp=EACH AList AS INT |
FOR Temp=EACH AList AS INT |
||
PRINT #Temp |
PRINT #Temp |
||
NEXT |
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 |
|||
== An Array == |
== An Array == |
||
Line 707: | Line 722: | ||
AnArray=0,1,2,3,4,5,6,7,8,9,10 |
AnArray=0,1,2,3,4,5,6,7,8,9,10 |
||
OPENCONSOLE |
|||
FOR X=0 TO 10 |
FOR X=0 TO 10 |
||
Line 713: | Line 730: | ||
NEXT X |
NEXT X |
||
PRINT |
|||
'a press any key message is automatic when compiled as console only. |
|||
CLOSECONSOLE |
|||
'Because this is a console only program. |
|||
END |
|||
</lang> |
</lang> |
||