Oxygen Basic

Programming => Problems & Solutions => Topic started by: chrisc on March 20, 2018, 08:09:52 PM

Title: how to declare pointer and use them?
Post by: chrisc on March 20, 2018, 08:09:52 PM
in PB we can declare pointer as

Code: [Select]
GLOBAL Sgp1 AS DWORD PTR

' and later use the pointer
 Sgp1 = CODEPTR(somelabel)

LOCAL Amm AS LONG
 Amm = @Sgp1[Amm]



how to do it in O2 ?
Title: Re: how to declare pointer and use them?
Post by: Aurel on March 20, 2018, 09:57:31 PM
I manot sure for array
but simple way is :

Code: [Select]
'pointer
string a = "Oxygen"
@p = a
print p  ' show Oxygen
Title: Re: how to declare pointer and use them?
Post by: Charles Pegge on March 20, 2018, 09:59:54 PM
This could be confusing since o2 uses the @ operator as codeptr or 'address of'

Code: [Select]
GLOBAL Sgp1 AS DWORD PTR

' and later use the pointer
 Sgp1 = CODEPTR(somelabel)

LOCAL Amm AS LONG
 Amm = @Sgp1[Amm]

Code: [Select]
sys Sgp1
Sgp1 =@somelabel
dim Amm AS LONG
amm=1
Amm = *(Sgp1+Amm)
print hex Amm 'result: 302
end

somelabel:
db 01 02 03 00 00

Title: Re: how to declare pointer and use them?
Post by: chrisc on March 21, 2018, 04:27:06 AM
Thanxx to both of you and i gonna test them out on a  program