-
I'm trying to understand and learn - but my brains are old, rusty and stuffed with loads of useless knowledge, that's why I still did not get it.
I know this "<=" as some comparison-operator. If it's used to assign values it would be enough to use just "=".
So does this assign the values to the array ordered from smallest to largest or what?
Or does it assign only values if the original value of the variable is smaller than the new one?
or is it just supposed to symbolize an arrow as "->" in some older c-dialect?
Edit: hours later :) ...does it mean to assign the count of elements to the variable enclosed in brackets?
-
rene
It is just a content of array ...
try this one:
Code:
INT arr[5]
arr[q] <= (1,2,3,4,5)
print str arr[2] ' show 2
so ,as you see is very clear what it is,right?
-
I tried this:
Code:
Uses "oxygen"
String src = RawText
'
#basic
'
Int arr[5]
Int q
arr[q] <= (1,2,3,4,5)
Print str arr[2] ' show 2
Print str q
'
terminate
'
End RawText
O2_BASIC src
If Len(O2_ERROR) Then
MsgBox 0, O2_ERROR : Stop
End If
O2_EXEC
Output:
3
0
???
Now I'm speechless
-
'<=' is use a multi-assign operator. Oxygen also accepts '=>' as used by Freebasic. Curly braces are also accepted:
long a[5]={1,2,3,4,5}
The reason for this flexi-syntax is to support clean layouts of data, including tabulations:
Code:
dim as long a[16]
...
'no need for brackets here
a=>
1, 2, 3, 4,
2, 4, 6, 8,
3, 6, 9,12,
4, 8,12,16
-
Aurel, Rene,
Correction here: Oxygen static arrays are dimensioned at compile-time. So the number of elements must be a constant. The new version will report the error.
%q=5
arr[q] <= (1,2,3,4,5)
-
strange: twice nearly the same content
Code:
Uses "oxygen"
String src = RawText
'
#basic
'
%q = 5
Int arr[q]
arr[q] <= (1,2,3,4,5)
Print str arr[2] ' show 2
Print str q
terminate
'
End RawText
O2_BASIC src
If Len(O2_ERROR) Then
MsgBox 0, O2_ERROR : Stop
End If
O2_EXEC
the above results wrong
Code:
Uses "oxygen"
String src = RawText
'
#basic
'
%q = 5
Int arr[q] <= (1,2,3,4,5)
Print str arr[2] ' show 2
Print str q
terminate
'
End RawText
O2_BASIC src
If Len(O2_ERROR) Then
MsgBox 0, O2_ERROR : Stop
End If
O2_EXEC
this one seems correct.
So the <= just means "populate the array"
Edit: I also had a few basic questions - already posted here
-
Charles ...
i know the quirks..:D
Rene
I use Oxygen directly ,not trough thinBasic