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 / compiler crash with string operations?

Author
Message
sprites r us
20
Years of Service
User Offline
Joined: 4th Mar 2004
Location:
Posted: 17th Mar 2004 12:21
Can someone please tell me why this code crashes the compiler when i send a string like "12.1" into it? (should be returned as "12.10")


spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 17th Mar 2004 12:28
Works fine on my pc (using patch 5.1)

Do you get an error or does it just crash out.

Here is the exact code I used to test, which outputs 12.10



Boo!
sprites r us
20
Years of Service
User Offline
Joined: 4th Mar 2004
Location:
Posted: 17th Mar 2004 12:43
maybe i need to patch it then.. dont know what version but i dont think i've patched it... it gives no error just shuts down..
sprites r us
20
Years of Service
User Offline
Joined: 4th Mar 2004
Location:
Posted: 17th Mar 2004 13:29
so i've done some tests... it is working fine ás far as putting the decimals, but whenever i call the funcion, the .exe crashes right after the function is done... strangely enough if i put wait key just after the function it stays there but as soon as i press a key, .exe crashes... This happens even if i put the function in it's own source file, like your example above. if i remove the function call the program runs on as usual... This has got to be a bug and a very strange one at that...
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 17th Mar 2004 14:07
I don't know your knowledge of DB so please don't take this wrongly.

What do you mean by 'exe crashes out'. If you don't have a main loop or a wait key, the program will obviusly run but then just quit back to windows or editor. This is how DB works! What else would you expect?

If this is not the case can you post all your code as it may be a different problem altogether.

Boo!
sprites r us
20
Years of Service
User Offline
Joined: 4th Mar 2004
Location:
Posted: 17th Mar 2004 15:05 Edited at: 17th Mar 2004 15:36
okay i wont take it the wrong way then even though i am tempted...

i mean the .exe (the temporary compiled one, btw i noticed i wrote compiler in my first post wich was obviously misleading) crashes giving me a windows "problem with 100m.exe" error and shuts down when i press ok... This happens after the function is done, whether or not i use my whole program or just your code. It goes as far as stopping for waitkey when that is pressed it crashes. if i rem out the function call nothing happens (i.e. program runs normally)

So basically:
*The function works
*It returns the right string as expected
*any call made after wait key crashes (yes a real windows crash) the exe

it's to weird, think i'm gonna cry

i appreciate any help so ofcourse i take it the right way

EDIT:
Also i tested reming out the entire code in the function so all it did was return the string it got from the call. Still crashes.. so it's not anything in the function that makes it crash it is simply calling the function that crashes it, apparently. I have several other functions in the prog and none of em crash it...

EDIT2:
On a brighter note, putting the function code in the main program makes it work, but on the other hand (the darker ) i will have to have these 10 lines of code in a zillion places... doh
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 17th Mar 2004 15:56
Since you arn't sure if you updated or not here is a link to the updates http://darkbasicpro.thegamecreators.com/?f=upgrades

If you want to check if you have updated then look in your dbpro directory. The updates leave a text file like upgrade5_1.txt for every one you have run.
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 17th Mar 2004 23:07
you could also just use gosub and make your private variables something like PRIVATE_varname_PRIVATE, then just gosub and return, functions DO act strangly, although some people insist they don`t ( see???...told you guys ), the trouble seems to be that it is an intermitant bug, sometimes you get it and sometimes the code will work fine (usualy while trying to demonstrate the problem ), I have had a function crash just because of a "wait 10" in the main loop, only reason I spotted it was the wait was added in and the code stopped working, removed it and it worked again, if the wait had already been there then I maybe would never have found what was causing it, just quirky compiler oddness if you ask me , maybe it will be improved in (bugfix) P6.

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, ATI radeon 9800 pro gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster, ups.
sprites r us
20
Years of Service
User Offline
Joined: 4th Mar 2004
Location:
Posted: 18th Mar 2004 09:44
Thanks for your help guys, i solved it by updating to 5.2 and the editor to 1.0.9b or sumthin...

however updating gave me a new problem... when i do for example 500/100 i randomly get either 4.999999999 or 5.00000001

weirder still i think...
Emperor Baal
20
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 18th Mar 2004 19:48
Quote: "however updating gave me a new problem... when i do for example 500/100 i randomly get either 4.999999999 or 5.00000001

weirder still i think... "


Oh, thats not a real problem, that's just how the cpu works. Im to tired to explain that right now, but im sure you can find some more information about that problem.

(NOTE: That problem is a real pain, ye know? A minor mistake (5.000000001, instead of 5.00000000) could make a a-bomb miss it's target )

Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
sprites r us
20
Years of Service
User Offline
Joined: 4th Mar 2004
Location:
Posted: 18th Mar 2004 23:11
well i did a workaround (again)
when i have like 12.53799999999999
i do *100 then nr-int(nr) (gives me 0.799999) then str$ and check if 3 letter is 5,6,7,8 or 9 if so i inc nr and when i print it i str$ it again and split in half with a dot in between... simple yet complicated

Login to post a reply

Server time is: 2024-11-26 09:40:24
Your offset time is: 2024-11-26 09:40:24