scripting engine

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Jony_Basic
Newbie
Posts: 4
Joined: Tue Jun 27, 2006 3:24 am
Location: New York
Contact:

scripting engine

Post by Jony_Basic »

I have implimented a scripting engine that works as follows, and I need
some advice as to how to call up the script.

script file:

Code: Select all

<h>                         'header
30,30,s1                   'coordinates of script #1 on the map
</h>                        'end of header
<s1>                        'beginning of script #1
some commands       'self explanitory
</s>                        'end of script #1
</>                          'end of file
the program will call this script file and check the header for matching
coordinates. If a match is found, the program will jump to the s# defined
in the respective header.

This is my dilemma:

If I decide to hold this file open for input for the length of the programs
run, I fear the program is liable to crash without warning due to
file access errors or some other problem related to holding a file open.
Perhaps my fears are completely illogical and there's no problem with
this method.

If I decide to only open the file when I need to read a script. I will load
the coords into the program then close the script file. the problem with this method is that constant opening and closing of a file may cause a
problem with the users hard drive. Of course I don't know, maybe it won't,
that's why I'm asking. also the fact that you are accessing the HDD at all
slows down the program by a bit. would it still be fast enough?

Please help me decide on a proper method of file access.
I hope to resolve this dillema by tomorow
any help is greatly appreciated, thank you. =D
sid6.7
Veteran
Posts: 318
Joined: Tue Jun 21, 2005 8:51 am
Location: west USA
Contact:

Post by sid6.7 »

if your appending the file you can keep it open
but if your doing something else you need to
open/close it as far as i know in QB.
Jony_Basic
Newbie
Posts: 4
Joined: Tue Jun 27, 2006 3:24 am
Location: New York
Contact:

Post by Jony_Basic »

The only thing I'm doing is opening the file for input. It only reads.
Can I hold the file open until the program terminates?
I know I CAN, but is it a good idea?
User avatar
Skyler
Coder
Posts: 16
Joined: Wed Jun 07, 2006 4:15 pm
Location: Delta Quadrant

Post by Skyler »

Well, if Windows continually accesses your hard drive for its virtual memory, I don't see why it would be bad for you to continually open/close a file. The only "open file" problems you should run into are if you're trying to access the file at the same time your program is reading it.
For God so loved the world he gave His only begotten Son that whosoever believeth on Him shall have everlasting life.
John 3:16
RyanKelly
Coder
Posts: 48
Joined: Sun Jan 22, 2006 6:40 pm
Contact:

Post by RyanKelly »

Most hard drives should be able to handle the continual access, and your operating system will most likely try to cache the information, but the real issue you'll face if a severe speed penalty. Depending on the amount of data you plan to store in your script, it might be a better idea to try and load all of it into memory, compiling it into a code if neccessary.
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

It really depends on the application. Reading scripts from the hard drive to run time-critical operations is never a good idea, but non-time-critical operations is fine and a good memory saver.
Jony_Basic
Newbie
Posts: 4
Joined: Tue Jun 27, 2006 3:24 am
Location: New York
Contact:

Post by Jony_Basic »

okay.
I'm opening the file at the beginning of the application.
I'm closing it when you close the application.
I access data from the file by means of the SEEK command to address
any byte in the file.
The program doesn't crash so far, it's relatively easy to use, and it's
running wicked fast. :D my program is speed intensive, therefore frame
rate is a priority.
I'm currently running at about 73-78 FPS. :wink:
Post Reply