"&" elaboration

Started by James C. Fuller, February 22, 2021, 03:48:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

James C. Fuller

Charles,
  Would you elaborate a bit more on "&"
In the help file description for the address of operator "@" you state:
@ is similar to the & operator in C.

   In the FuncPointers1.o2bas it appears & is used similar to a c++ reference?

"&" is also listed as a substitute for "and" in the O2 help file

I am enjoying going back through all the examples, many must be new since I last tried O2( Well that's not necessarily true my memory is getting a bit flaky) :)

I have encounter a few issues with the examples but I'll wait a bit and list them all later.

James
  •  

Charles Pegge

Hi James,

'&' can be used as a pointer, though my preferred symbol is '@'

I thoughtof 9 different uses for '&'. It is the most overused symbol in Basic, especially in o2 :)


'USES OF '&'
'
'print &h101 '257
'print &o101 '65
'print &b101 '5
'print "ok" & "ay" 'okay 'string concatenator
int a=15
'print a & 19 'bitwise and: 3
'print a && 19 'logical and: -1
'print (&a) 'address eg: 5844992
'int a& = 67 'name char suffix
'print a&    '
'int a&b = 67 'name embedded character
'print a&b    '


Zlatko Vid

Quote'print "ok" & "ay" 'okay 'string concatenator

it is ok
but i prefer more logical to me

'print "ok" + "ay" 'okay 'string concatenator
  •  

Charles Pegge

Yes, there are alternatives for nearly all of the '&' symbol.

Only '&&' is required for logical 'and'


'print &h101 '257
'print 0o101 '65
'print 0b101 '5
'print "ok" + "ay" 'okay 'string concatenator
'int a=15
'print a and 19 'bitwise and: 3
'print a && 19 'logical and: -1
'print @a 'address eg: 5844992

Theo Gottwald

Hallo Charles

I guess you should just copy that paragraph and put it into the help-file.