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.

DarkBASIC Professional Discussion / need help with types and dims

Author
Message
nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 28th Oct 2011 23:40
i am confused, if i have declared type with a number of members and dim to store objects of that type how can i retrieve the data from an object of that type. Like if i have brush type with members id,posx,posy,posz how can i retrieve that data?
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 29th Oct 2011 00:05
Something like:



Hope that helps a little...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Daniel wright 2311
User Banned
Posted: 29th Oct 2011 00:30
or something like this?



my signature keeps being erased by a mod So this is my new signature.
nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 29th Oct 2011 02:13
ok so why this code crashes the program i don't see the error because it compiles, this is just a piece of code because i have made more then 10.000 lines of code

Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 29th Oct 2011 03:13
Quote: "BrushNum=array count(Brush())+1"

I'm not quite sure what you are going to be doing with it, but that will cause problems unless changed before reaching the if clause (since the array index BrushNum will point to doesn't exist).

Slightly off topic, but you needn't declare an array as global since they are global by default (you can make them scope-specific by using the local keyword though).


"Why do programmers get Halloween and Christmas mixed up?"
nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 29th Oct 2011 19:03
well that might be the problem but if BrushNum is 0 i have the same crash at the point where data needs to be passed like in the part after button clicked part of code
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 29th Oct 2011 19:10
do you know at which BrushNum is crashing. the array size is 256 so if BrushNum gets bigger that that it would crash

nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 29th Oct 2011 19:18
no i don't i am totally confused i have declared all globals needed for this all types and a dim in one file, in the other there is a function for putting all data into type and then there is a function to receive that data and save it into file.

how would you do this?
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 29th Oct 2011 19:42 Edited at: 29th Oct 2011 19:43
make some sort of log system which will save the value of the BrushNum variable every time button is clicked so when it crashes you will know which number is the cause of the crash.

But even without that i'm quite sure the value increases quite fast when you click the button so it gets to the 257 which is cause of the crash.

You have to make sure that BrushNum if increased only once every time the button is clicked

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 29th Oct 2011 20:23 Edited at: 29th Oct 2011 20:27
Here's a suggested revision of your code to clear it up a bit. You've declared variables that seem not to have any use but a temporary one. Also it's difficult to work out what is 'local' or 'global', so I suggest tagging variables that are with '_'. For instance '_brush' or you could go with the classic lowercase 'G' before (gBrush). Also add comments to everything so you know what it does. Helps when looking back at your code.

nruser
18
Years of Service
User Offline
Joined: 22nd Dec 2007
Location: Serbia
Posted: 2nd Nov 2011 16:28
there is most probably a serious bug with this for example take fading teletype code snippet that is done by phaelax and move his type definitions to be on the end of the program and see what happens, i will try to find some temporary workaround for this, thanks for help.

Login to post a reply

Server time is: 2026-07-11 12:00:38
Your offset time is: 2026-07-11 12:00:38