Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Using function with Pointer to array as parameter


martel Mar 15, 2019 02:10 PM

I'm playing around with pointers and found a weird case where my code compiles in both scenario, but it seems to be impossible to reference an array position through a variable.

Can someone explain to me why this code works:

Public Status_Log(9) As String * 255

Function update(ptr As Long)

    !ptr(2) = "Hey"

EndFunction

'Main Program
BeginProg
    Scan (1,Sec,0,0)
        update(@Status_Log)
    NextScan
EndProg

But this code doesn't:

Public Status_Log(9) As String * 255

Function update(ptr As Long)
    Dim i As Long
    i = 2
    !ptr(i) = "Hey"

EndFunction

'Main Program
BeginProg
    Scan (1,Sec,0,0)
        update(@Status_Log)
    NextScan
EndProg

I would really appreciate any light shed on this - thank you!

Log in or register to post/reply in the forum.