Global Pointers
Posted: Wed Apr 09, 2008 1:20 pm
Can a Pointer be Global?
I need to use pointers in procedures (from where imported functions are called) and do not want to pass them as parameters, but instead have access to them as global.
It works fine as long as I have the call for the imported function in the main program, but when I move the same to a procedure problem occur.
I have the following code:
But if I now declares the pointer as global as follows...
...and move the last line to a procedure like this...
...and call that procedure with a...
It stops with a invalid memory access.
So I assumes that there's some problem with the pointer here. Can anyone explain the reason for this problem and how it should be solved?
I need to use pointers in procedures (from where imported functions are called) and do not want to pass them as parameters, but instead have access to them as global.
It works fine as long as I have the call for the imported function in the main program, but when I move the same to a procedure problem occur.
I have the following code:
Code: Select all
;-------------------------------------------------
Import "calc32.lib"
julday (a.l, b.l, c.l, d.d, e.l, f.l=0) As "_julday@24"
EndImport
Prototype.d FunctionA (a.l, b.l, c.l, d.d, e.l, f.l=1)
*PointerA.FunctionA=@julday()
;-------------------------------------------------
juliandayUT.d=*PointerA (year.l, month.l, day.l, time.d, flag.l)
;---------------------------------------------------Code: Select all
;---------------------------
Global *PointerA.FunctionA=@julday()
;--------------------------Code: Select all
;----------------------------------------
Procedure Procedure JulianDate()
juliandayUT.d=*PointerA (year.l, month.l, day.l, time.d, gregflag.l)
EndProcedure
;---------------------------------------------------Code: Select all
;--------------------------------------
JulianDate()
;------------------------------------So I assumes that there's some problem with the pointer here. Can anyone explain the reason for this problem and how it should be solved?