B4J Question How to find my EXCEL file ?

CR95

Active Member
Licensed User
I would like to load parameters from an external EXCEL file.
I loaded the file by using B4J files system command. File has been copied in "Files" folder of my program.
I understood that external loaded files are in the "DirAssets" folder;
But my program (B4J) cannot find it
If File.Exists(File.DirAssets,"MesMacros.xls") = True Then
Log ("File is founded")
Else
Log ("No file in the folder")
End If
Thanks for your help
 

roerGarcia

Active Member
Licensed User
Longtime User
Try and see Log(file.dirassets) and the extension of your file, xls, xlsx?
C:\Users\roerg\OneDrive\DOCUME~1\ProjB4J\PROJECTNAME\Objects - DIRAPP
C:\Users\roerg\AppData\Roaming\YOURAPP - FILE.DIRDATA("YOURAPP")
 
Upvote 0

Chris2

Active Member
Licensed User
Longtime User
File.Exists does not support the File.DirAssets folder.
fileExists.png

You should probably use File.DirData("AppName") instead.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
But is it possible to verify that the file was not forgotten ?
I don't understand what you are trying to do. If you added the file to the Files tab then the file will be there. If you forgot to add it then you will get an error and then add it. There is nothing that needs to be verified.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
So simple !
But is it possible to verify that the file was not forgotten ?

if it is a file that you plan to add in runtime like downloading it or create it then you should use file.dirapp() instead and then you can check if the file exists. but as erel already said if it is a file that must be inside the app when it is created then you will need to add it to file.dirassets and this is why a check does not make any sense.
 
Upvote 0

CR95

Active Member
Licensed User
Thanks for this help

My idea is to save all the parameters in an external Excel file (easier to set-up for non programming user)
Second reason is because I understood that all parameters have to be in "main" activity in order to be available to other activities (and my main activity becomes too long and not easily readable)
That brings other issues.

My program “jumps” from an activity to another without problem (thanks to “CallSubDelayed2 »)

But when I come back to main program and if the user wants to quit :

if I use “Activity.Finish » as recommended, my phone shows the previous activity screen (which should be still in memory ?)

if I use « ExitApplication », first issue is that my call to a sub in starter is not run, and second issue, I got a black screen on my phone (with only the title of my application)

Could you help to quit correctly ?

B4X:
Sub ButtonExit_Click    ' Bouton Eteindre
    Log ("Exit Click")
    CallSubDelayed2(Starter,"Transmet", "MExtinction")    ' Macro to shut off equipments
    ExitApplication
    ' Activity.Finish
End Sub
 
Upvote 0
Top