Posts: 4
Threads: 1
Joined: Feb 2024
Reputation:
0
I just downloaded qb64 and it seems marvelous! I had written several programs in QB4.5 and I would like to review and revise some of them. Last time I used QBasic was inside DOSBox, but did not like it very much.
Now, I try to run a program that reads the coastline coordinates of the continents and prints maps, but the qb64 exe file does not find the coordinates file, though it is in the same (GEOGRAFY\) directory:
OPEN "GEOGRAFY\PMAP1.PNT" FOR RANDOM AS #1 ...
What is the correct file address of PMAP1.PNT?
Posts: 214
Threads: 32
Joined: Apr 2022
Reputation:
68
02-13-2024, 02:22 PM
(This post was last modified: 02-13-2024, 02:23 PM by MasterGy.)
Hi !By default, it saves to the same location as your QB64 executable. You can change this behavior to make it save wherever your source code is located by clicking "Run" and then selecting "Output EXE to Source Folder".
Posts: 54
Threads: 12
Joined: Apr 2022
Reputation:
2
If the folder "GEOGRAPHY" is inside QB64PE folder, try this:
OPEN ".\GEOGRAFY\PMAP1.PNT" FOR RANDOM AS #1
10 PRINT "Hola!

"
20 GOTO 10
Posts: 3,447
Threads: 376
Joined: Apr 2022
Reputation:
345
Another really easy and flexible option is now:
files$ = _OPENFILEDIALOG$("Open File", "", "*.PNT", "Map files", -1)
IF file$ = "" THEN END 'user hit cancel and didn't enter a pnt file.
OPEN file$ FOR RANDOM AS #1
Like this, you can navigate and choose which file you'd like to open and use, rather than just hardcoding the name and path into your program.
Posts: 4,698
Threads: 222
Joined: Apr 2022
Reputation:
322
02-13-2024, 03:23 PM
(This post was last modified: 02-13-2024, 03:24 PM by bplus.)
@emfril Welcome!
MasterGy's tip addresses the #1 problem for old QB fans experiencing QB64 for first time, so i am repeating it. You must click the "Output EXE to source folder" so that there is a bullet next to that option whenever you click the Run menu in the IDE. This puts the compiled .exe program in the same folder as your .bas and that should be same folder as your project files for that .bas source.
Steve's idea is good too, with an extra line or 2, you can choose from a multitude of files to run in your program!
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever
Posts: 3,447
Threads: 376
Joined: Apr 2022
Reputation:
345
"./" if it's in the same directory as the BAS file and EXE. (".\", depending on OS.)
You can always hard code the FULL PATH, as long as that file isn't going to move on you. "C:\My Folder\My Subfolder\My File.txt"
Posts: 4,698
Threads: 222
Joined: Apr 2022
Reputation:
322
02-18-2024, 10:50 AM
(This post was last modified: 02-18-2024, 10:57 AM by bplus.)
And _CWD = "Current Working Directory", QB64 has that built in and tracks for you. You can use it to check where you are in your folder system as your program is running.
And also you can use _FileExists(PathedFileName$) to check that the file (at the optional named path) does exist and you can open it without error.
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever