Reading file - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Reading file (/showthread.php?tid=2442) |
Reading file - emfril - 02-13-2024 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? RE: Reading file - MasterGy - 02-13-2024 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". RE: Reading file - Ikerkaz - 02-13-2024 If the folder "GEOGRAPHY" is inside QB64PE folder, try this: OPEN ".\GEOGRAFY\PMAP1.PNT" FOR RANDOM AS #1 RE: Reading file - SMcNeill - 02-13-2024 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. RE: Reading file - bplus - 02-13-2024 @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! RE: Reading file - emfril - 02-18-2024 (02-13-2024, 02:22 PM)MasterGy Wrote: 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". Yes, I made this mistake initially but fount it out soon enough. It didn't correct the problem though... RE: Reading file - emfril - 02-18-2024 (02-13-2024, 02:32 PM)Ikerkaz Wrote: If the folder "GEOGRAPHY" is inside QB64PE folder, try this:No, the same result: Line 446 (in main module) Path not found I wish there was a way to find out *where* it's looking for the file, then it would be easy to correct the mistake... What should the path should be if I make a copy of the pnt file in the same folder as the bas and the created exe files? RE: Reading file - SMcNeill - 02-18-2024 "./" 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" RE: Reading file - bplus - 02-18-2024 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. RE: Reading file - emfril - 02-18-2024 (02-18-2024, 10:50 AM)bplus Wrote: 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.Thanks! This works: OPEN "C:\MYSTUF~1\MYFILE~1\QB\GEOGRAFY\PMAP1.PNT" FOR RANDOM AS #1 LEN = LEN(PNTData) The source file and the executable file are in the folder: \GEOGRAFY\GEAMAP\ So want should have been the correct abbreviated form of the statement? Also, in QB64 do I have to use MYSTUF~1 as in QBASIC and DOS (instead of MYSTUFF)? |