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 / Reading text and having a problem...

Author
Message
MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 31st Jul 2003 10:11
It seems that when I open a file to read it and then read it string by string, the second time seems to not appear as the value it is even though when I print it out it is what it's supposed to be.

My program is going to read in text from a file and then store it for later use. It's a text rpg (wanted to make something simple yet extendable), if anyone wanted to know. The attached code is the place where the problem lies. To make it work, all you need to do is have a subdirectory from the compiled program called "worlds" and have main.world (a simple .txt file with a renamed extension, done in notepad) with 2 lines:

Classes:
Fighter

that's all it reads so far, because when I tested even that simple bit it started giving me crap.

The output it gives me:

Read 'classes:'
Read 'Fighter'
Main.world is not in the correct format.
Correct this yourself or get another copy from the distributor.
Press any key to end the program.

What it is reading are the correct things, yet it is telling me they are wrong. If I can do a program that reads BSP entities, I should be able to write this...

Or maybe not .
My friends' and my website for DBPro Programming:
http://unseenstudios.netfirms.com
Ralen
23
Years of Service
User Offline
Joined: 22nd Jul 2003
Location:
Posted: 31st Jul 2003 11:23
open to read 1,"worldsmain.world"

don't you need some / in there?

open to read 1,"/worlds/main.world"

MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 31st Jul 2003 11:38
Whoops, typo.

It's supposed to be 'worlds\main.world'.

My friends' and my website for DBPro Programming:
http://unseenstudios.netfirms.com
the_winch
23
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 31st Jul 2003 16:28 Edited at: 31st Jul 2003 16:28
The problem is the

if stringbuffer$ != "Fighter"

Use

if stringbuffer$ <> "Fighter"

or perhaps

if stringbuffer$ not "Fighter"

insted. I don't think db uses !. I can't tell for sure as I can't find anything in the help.
MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 2nd Aug 2003 00:47 Edited at: 2nd Aug 2003 00:49
Hmm...that would make sense, the_winch, but two things:

1. Wouldn't it give me a compiler error if I was using the wrong conditional statement?
2. Why does it work for "classes:" and not "Fighter"?

Thanks for the help...I'll keep trying to think of an alternate method so I can just forget the problem.

My friends' and my website for DBPro Programming:
http://unseenstudios.netfirms.com
Lord Belial
23
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 2nd Aug 2003 01:05
I had some problem with the read string command. I've put a comment in the bug forum.

Lord Belial
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Aug 2003 01:38 Edited at: 2nd Aug 2003 01:39
Changing the != to <> in both places makes the program run correctly, but I do agree that in DBPro terms, != does not make any sense and should probably generate an error.

I'm using this (very slightly changed) code:


and a text file 'main.world' with this in:
MasterInsan0
23
Years of Service
User Offline
Joined: 14th May 2003
Location: United States
Posted: 2nd Aug 2003 02:01
Hmm...seems like I need to be getting more sleep.

It was simply a typo in my own worlds file. I read "classes:" and checked it against "Classes:".

If anyone would like to flame me for being an absolute moron, please do so. I think I need it .

This does raise a question though. Is there a way to convert a string or character to lowercase? That way I could read a string, convert it to lowercase, and check aganist the lowercase version of it, to prevent any future problems like this.

My friends' and my website for DBPro Programming:
http://unseenstudios.netfirms.com
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Aug 2003 02:17
Yes, you can use UPPER$() or LOWER$().

Login to post a reply

Server time is: 2026-07-23 02:37:17
Your offset time is: 2026-07-23 02:37:17