I tried to open some to my program associated files
It works.
But:
App_Scriptpath holds/returns not the path of my App (.exe) - instead it holds the path where the file to open is located.
That messes up all subfolder-locations that my script is supposed to work with.
Attachement contains example thinBaisc-Source + bundled exe + subfolder with some file to open by rightclick, choose app_ScriptpathTest.exe to open the .XXX123- file for a test.
this is the Main-Scripts code, so you can imagine what awaits you:
'---------------------------------------------------------
' YOU READ THE CODE OF app_ScriptpathTest.tBasic
' Test to OS_Command(s)
Uses "Console", "OS", "FILE"
#INCLUDE "Scriptpath2.tBasicU"
Function TBMain()
Local sFile As String
PrintL "This is App_Scriptpath:"
PrintL APP_ScriptPath
PrintL "-----------------------"
If OS_GetCommands >= 2 Then
sFile = Mid$(OS_GetCommand(2), 2, Len(OS_GetCommand(2)) - 2)
PrintL "This is OS_Command(2)-Parameter without quotes:"
PrintL sFile
PrintL "-------------------------------------------------------------"
PrintL "Press any key to continue"
PrintL "."
PrintL "."
PrintL "."
WaitKey
ShowTextFile(sFile)
EndIf
PrintL "Press any key again to End"
WaitKey
End Function
' END OF CODE
'------------------------------------------------------
'follows second unit
'this is just the dummy-include with some sub, so we have a real bundle
Sub ShowTextFile(ByVal sFile As String)
Local fNum As DWord
fNum = FILE_Open(sFile, "INPUT")
If fNum Then
PrintL "This is File-Content of associated file:"
PrintL "#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#"
PrintL "#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#"
While Not FILE_EOF(fNum)
PrintL FILE_LineInput(fNum)
Wend
PrintL "#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#"
PrintL "#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#"
FILE_Close(fNum)
EndIf
End Sub
If run this from thinAir it will show the main-script- but that's not the intention.
So I added in the subfolder some simple textfile with special file-extension .XXX123
leave the textfile in subfolder otherwise you won't see if app_scriptpath is wrong (which you get displayed on first console-printout)
rightclick the .XXX123-file and select "app_ScriptPathTest.exe" to open it - check which App_Scriptpath console shows.
btw. I use 1.9.5.0 but the options-list does not offer this so I had to choose 1.9.2.0 as affected version