Qbasicnews.com

Full Version: Loading a file when qb opens...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a command you can use with qb to load a program after qb opens? Sorta like /run, but without actually running the program? I'm pretty sure you can't, so a yes/no answer will do. Thanks
ya. all you do is put the file name

Code:
QB remline.bas
:roll: of course
Thats pretty obvious.. didn't you know that r@dioman?

hides* I didn't know... lol..... *feels stupid*
lol, i didn't know until i looked it up in the help file =P
sometimes we forget the most basic things. I've never needed to open a file using that method until now.
In Windows, just drag the .bas file over qb.exe (or it's shortcut). That basically tells Windows to use the filename of the file you dragged as the commandline.
Quote:In Windows, just drag the .bas file over qb.exe (or it's shortcut). That basically tells Windows to use the filename of the file you dragged as the commandline.

To elaborate...compile the following code:

Code:
DEFLNG Z  'make z a long int...for speed
c$ = COMMAND$   'Look, ma...c$ contains the path to the "dropped" file

DIM a AS STRING * 1   'a "one character" string
z = 1             'the byte position in the file
OPEN c$ FOR BINARY AS #1    'doesn't need to be bin if you know your file contains text/carrage returns...

DO
GET #1, z, a        'get a byte of the file
PRINT a;             'print said byte
z = z + 1            'increment the file pointer
LOOP WHILE NOT EOF(1)   'until the end of file is detected

PRINT                        'make a new line
INPUT "Enter to contiune", x       'pause for input before closing window...

END   'uh...if this needs explaining, you're in trouble!!!

Then..."drop" a file onto the exe...it will open the file, and print it's contents, one byte at a time. This is a convenient way to "open and use" a file, but it only works if you compile your program...to run from the QB IDE, you need to make provisions to provide a valid path...

Joe (oops...I'm really mango)