Macro... (hum, not sure this is the correct word)

skipsy

Member
Licensed User
Longtime User
Hello all,

I was wondering if it is possible to use what I call "macro" in the B4A editor.
OK, stop scratching your head!
Here is what I am trying (this is an exemple) :
I am working on AVD emulator (when Im outside) and my tablet (at home).
With the emulator files are stored in "mnt/sdcard" that I could replace by
"File.DirRootExternal". On the tablet I have 2 SDcard slot + 2 USB. I have to
mention the path "/mnt/extsd/sdcard1".
SO, Is there any way to have something like :
B4X:
#SDPATH : /mnt/extsd/sdcard1
That I could comment and replace by
B4X:
#SDPATH : File.DirRootExternal
and use #SDPATH in my code.
B4A will then compile as if the text had been replace manually.
(well, not easy to explain in english).

If there is no way, I can use a blogal variable but I it not clean.

Thks,
W.W.
 

Mark Read

Well-Known Member
Licensed User
Longtime User
Hello Skipsy,

just a thought but you could use for example the OSLibrary which gives system info. Check the value of Model and set the path accordingly.

B4X:
Sub Globals
     Dim Sys As OperatingSystem
End Sub

Sub Activity_Create(FirstTime As Boolean)
     Sys.Initialize("")
     if Sys.Manufacturer="sdk" then   'shows in the emulator, otherwise you see the tablet or mobile model
          SDPATH="/mnt/extsd/sdcard1"
     else
          SDPATH =File.DirRootExternal
     end if

.... rest of program

Best regards
Mark
 
Upvote 0

skipsy

Member
Licensed User
Longtime User
OK.
I just wanted to be sure there is no "elegant" way to do that.

Thank you,
WW
 
Upvote 0
Top