Author Topic: how to declare pointer and use them?  (Read 1097 times)

0 Members and 1 Guest are viewing this topic.

chrisc

  • Guest
how to declare pointer and use them?
« 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 ?

Aurel

  • Guest
Re: how to declare pointer and use them?
« Reply #1 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

Charles Pegge

  • Guest
Re: how to declare pointer and use them?
« Reply #2 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


chrisc

  • Guest
Re: how to declare pointer and use them?
« Reply #3 on: March 21, 2018, 04:27:06 AM »
Thanxx to both of you and i gonna test them out on a  program