Running FNXBasic 2.1 apr_2012 and compiling for XP x86 & Win7 x64 - symptom is on both. I admit I`ve only had FNXB a few days since I switched from QB64 (didn`t like the HUGE set of runtime DLLs). I also admit I`m using it for CLI apps, and yea its really suited for Visual-type apps, but I just love that it bundles everything into 1 EXE.
Looks like FNXBasic file.open (filestream) always writes to the original app path (i.e. where the app resides) when read/writing files.
My text manipulating app is located in C:UTILS (included in Windows path).
I tried to force it to write to current path with these tests (both were unsuccessful).....
file.open("."+cmdofile$)
and
file.open("%cd%"+cmdofile$)
When I "CD " (C:) and run against a text file in C:, an interesting thing happened for the 2nd test:
>>Runtime error: Cannot create file "C:UTILS\%cd%list.txt"
(this is how I know its forcing the app path)
Any ideas? I cannot use the APPNAME$ FN because that returns exactly the above, is there something like a CURRPATH$ FN that I don`t know about? Basically, if I am in C: I want file.open to write in C:, if I am in C:My Documents, I want that directory, etc. etc.
Thanks in advance!
Uses app path instead of curr path for file.open
Uses app path instead of curr path for file.open
After borrowing code from the member writing the mp3 player, I just used kernel32 call to get CurrPath. This will work. But I still think FNX Basic should default file.open to current working path (you can always modify that by leveraging the APPNAME$ FN and using just the path portion). Shouldn`t have to work so hard !
Declare GetCurrPath As "GetCurrentDirectoryA" of "kernel32"
lBuffer as Integer
lptstr as String byaddress
end declare
Dim CurrPath as String
GetCurrPath.lBuffer=255
GetCurrPath.execute
currPath=GetCurrPath.lptstr
PRINT "CURRPATH=`";CurrPath;"`"
WHILE INKEY$="":WEND
Declare GetCurrPath As "GetCurrentDirectoryA" of "kernel32"
lBuffer as Integer
lptstr as String byaddress
end declare
Dim CurrPath as String
GetCurrPath.lBuffer=255
GetCurrPath.execute
currPath=GetCurrPath.lptstr
PRINT "CURRPATH=`";CurrPath;"`"
WHILE INKEY$="":WEND
Uses app path instead of curr path for file.open
Moral of the story, always include a fully-pathed filespec (even if you have to recreate it by calling GetCurrentDirectoryA), otherwise FNX Basic defaults to the install directory of your app.
If you fully-path the filespec, it uses that.
If you fully-path the filespec, it uses that.
Uses app path instead of curr path for file.open
have anibody tried dir$?
the current path is dir$("@").
I hope this will help.
best regards
the current path is dir$("@").
I hope this will help.
best regards