Posts: 5
Threads: 2
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: 134
Threads: 24
Joined: Apr 2022
Reputation:
37
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: 46
Threads: 9
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: 2,695
Threads: 326
Joined: Apr 2022
Reputation:
217
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: 2,695
Threads: 326
Joined: Apr 2022
Reputation:
217
"./" 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: 3,932
Threads: 175
Joined: Apr 2022
Reputation:
215
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.
b = b + ...