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 / Hmmm... Problems with functions...

Author
Message
WarWolf
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 27th Jan 2003 11:23
File handling commands doesn't seem to work inside functions. Neither does if-statements. Is this a known problem or is it just me?
I didn't steal it!
jasuk70
22
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 27th Jan 2003 12:38
I use file commands and IF statements inside functions all the time.

Are you trying to write variables and do IF's on variables defined outside the FUNCTION? If so you need to make them global for the function to see them (Dimensioned arrays are automatically global when DIM'd outside the function.

e.g.

GLOBAL MyVar AS INTEGER will make MyVar global and can be seen inside a FUNCTION.

Jas
WarWolf
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 27th Jan 2003 13:10
I am trying to read and write local variables to a file. The problem is that the compiler says that the parameters are wrong, but they are clearly not.
write file 1,temp
ís an example of code that doesn't work.

When I move the code outside the function it works perfectly. Strange. I've had many strange problems like this with DBPro, I figure it might be something wrong with my CD.

I didn't steal it!
WarWolf
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 27th Jan 2003 13:12
Oh, and when I use if-statements it says that the endif is "out of place".

For example,
if a=1
print "A is 1"
endif
doesn't work. endif is out of place.

I didn't steal it!
Bangla
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: Sweden
Posted: 27th Jan 2003 14:03
I also have problems with IF-statements inside functions, the program crashes when trying to run the code. Very strange...

400 Mhz, 120 Meg, TNT2 - and then some...
Richard Davey
Retired Moderator
23
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 27th Jan 2003 14:19
Post your code. I've not encountered any problems with IF statements inside a function either.

Cheers,

Rich

"Gentlemen, we are about to short-circuit the Universe!"
DB Team / Atari ST / DarkForge / Retro Gaming
WarWolf
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 27th Jan 2003 16:56
I broke down the code to only the skeleton and the erroneous parts, since I can't post the entire code.



and this code is in the file functions.dba:



I recently tried this code on another computer, and it worked there, so I guess it's only my version...

I didn't steal it!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 27th Jan 2003 18:40
Have you installed Patch 3.1 ?

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
WarWolf
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 28th Jan 2003 12:13
Yes, I have patch 3.1...
Could it be something wrong with my CD? Printed wrong or something?

I didn't steal it!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 28th Jan 2003 15:08
Try re-installing and then installing the patch again.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
WarWolf
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 29th Jan 2003 12:10
MrTAToad, I have tried reinstalling it several times, doesn't work. Hmmm...

I didn't steal it!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 29th Jan 2003 14:14
Its the returns in the function statements again! Try removing those...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
WarWolf
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 29th Jan 2003 14:52
What do you mean TaToad?
The thing is that the compiler says that the parameters for write file and read file is wrong, and that endif is out of place.

I didn't steal it!
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 29th Jan 2003 14:56
Someone else came across a problem with returns in function cause problems elsewhere...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
WarWolf
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 29th Jan 2003 16:41
Aaah, thats right. Anyway, it doesn't help me... Better email DBS about it.

I didn't steal it!
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 30th Jan 2003 00:28
i would suggest using a Long instead of a File ... i know the manual note they're the same but they're not

Byte - Byte or Short
Word - Word
Long - Dword
Float - Float

also ... Patch 3.x caused some problems whilsty fixxing others.
In each patch there are features that work and some that don't - quite weird.

Anata aru kowagaru no watashi!

Login to post a reply

Server time is: 2025-05-17 13:54:16
Your offset time is: 2025-05-17 13:54:16