Author Topic: "&" elaboration  (Read 1910 times)

0 Members and 1 Guest are viewing this topic.

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 599
  • User-Rate: +11/-8
"&" elaboration
« on: February 22, 2021, 03:48:22 PM »
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
« Last Edit: February 22, 2021, 03:51:39 PM by James C. Fuller »

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 879
  • User-Rate: +33/-1
    • Charles Pegge
Re: "&" elaboration
« Reply #1 on: February 23, 2021, 12:50:45 AM »
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 :)

Code: [Select]
'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    '

Offline Zlatko Vid

  • Sr. Member
  • ****
  • Posts: 298
  • User-Rate: +2/-2
Re: "&" elaboration
« Reply #2 on: February 25, 2021, 10:28:44 AM »
Quote
'print "ok" & "ay" 'okay 'string concatenator

it is ok
 but i prefer more logical to me

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

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 879
  • User-Rate: +33/-1
    • Charles Pegge
Re: "&" elaboration
« Reply #3 on: February 25, 2021, 04:32:00 PM »
Yes, there are alternatives for nearly all of the '&' symbol.

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

Code: [Select]
'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

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 1058
  • User-Rate: +30/-4
  • Gender: Male
    • it-berater
Re: "&" elaboration
« Reply #4 on: March 09, 2021, 09:10:11 PM »
Hallo Charles

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

Offline Nicola_Piano

  • Full Member
  • ***
  • Posts: 111
  • User-Rate: +0/-0
Re: "&" elaboration
« Reply #5 on: February 02, 2022, 10:49:04 PM »