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 Discussion / help with reading from a text file

Author
Message
ico2
21
Years of Service
User Offline
Joined: 3rd Jan 2004
Location:
Posted: 25th Jan 2004 13:10
the first question i have is how do i get my program to read a word from a text file and if it is a certain word then read the next word on the line and if it is not then go to the next line.
then if the next word on the line is something then load the rest of the line as a string.

thanks very much
ico2
VishalC
21
Years of Service
User Offline
Joined: 14th Jan 2004
Location:
Posted: 25th Jan 2004 16:33
that would depend on what words you looking for. if you need to look for the same words on each line then its quite simple.

you have to read the entire line as a string. then parse the line into seperate strings and check if they are the same as your word. could you explain your problem more clearly,perhaps give an example? it will make it easier to help you.

If it wasn't for the last minute, nothing would get done!
ico2
21
Years of Service
User Offline
Joined: 3rd Jan 2004
Location:
Posted: 25th Jan 2004 16:59
i need it so if use=1 then it searches down for the next use command but won't go past a <newob> command.
and the when if finds the :use: command and the next word was (say) then it would output the rest of the line to the string say$ and if it was (startanimation) then it would send the next number on the line to the function startan(number) etc
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 26th Jan 2004 09:45
Heh, you'd have an extremely hard time doing that, you're basically trying to write your own interpreter ( ie, you're writing another scripting language ).

You can do the "use say" one, but that would require you to use parsing, have a look at the other post on this forum by cookyzue.

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
ico2
21
Years of Service
User Offline
Joined: 3rd Jan 2004
Location:
Posted: 26th Jan 2004 22:43
i am writing a point+click adventure game and want to have the script for each level as a seperate file that my game can interpret.
ico2
21
Years of Service
User Offline
Joined: 3rd Jan 2004
Location:
Posted: 26th Jan 2004 22:53 Edited at: 26th Jan 2004 22:55
this is what i managed to make so far, it does not work properly (whatever you put as action number it searches for look) and i can't get it to search for a further word in the string, but it almost fit's the purpose, i now only need to get the other words to be checked and then i am finished.
if anyone want's to try this out then it uses a text file with the code in, and i know i used the file extension for a screensaver but aaaahh well.

for some reason it won't let me use the code box below where i am typing this so i have to use the *[*code*]* tag.

ico2
21
Years of Service
User Offline
Joined: 3rd Jan 2004
Location:
Posted: 26th Jan 2004 22:56
which strangely seems to do the same thing

Login to post a reply

Server time is: 2025-05-22 12:16:58
Your offset time is: 2025-05-22 12:16:58