Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / What did I miss

Author
Message
DBDork
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location:
Posted: 2nd Dec 2002 10:08
Hi,

Simply trying to declare a global type and access it from a function, but it does'nt work (aka I musta messed something up). See the example below.

Thanks in advance,

For example:

TYPE _gb
gXSize AS Integer
gYSize AS Integer
gBlockSize AS Integer
ENDTYPE

----------------

global gb as _GB
gb.gXSize=10
gb.gYSize=17
gb.gBlockSize=10

*** This works correctly***

printat(0,0, str$(gb.gXSize)+"--------"+str$(gb.gYSize))

do
draw()
loop


function draw()
set current bitmap 0
copy bitmap 100, 0
rect(0,0,639,479)

x1=gb.gXSize

*** Does'nt work, comes up as 0 when it should be 10 as assigned in the beginning ***

printat(0,0, str$(x1)
*** it wont accept str$(gb.gXSize) as the parameter either ***
sync
endfunction
indi
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 2nd Dec 2002 18:21
there was a bug recently in patch 3.0 and is fixed in patch 3.1 apparantly with integers and types.

I prefer to use an array like this method.





DBDork
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location:
Posted: 2nd Dec 2002 20:48
Many Thanks, found patch 3.1 (did'nt realize there was one above 3.0 available) and it works perfectly for now I had tried floats as well and the same problem existed.

Many thanks to the dbpro team for the object oriented additions to the langauge.

Login to post a reply

Server time is: 2024-04-23 08:47:27
Your offset time is: 2024-04-23 08:47:27