Gambas executable entry value
Posted
#1
(In Topic #1179)
Regular

Code
Exec ["/home/bill/GambasFolder/Executable/DocsViewer.gambas"]
How can I provide an entry value (a file name) to DocsViewer.gambas?
Posted
Guru

bill-lancaster said
I run a gambas executable from another gambas project by:-Code
Exec ["/home/bill/GambasFolder/Executable/DocsViewer.gambas"]
How can I provide an entry value (a file name) to DocsViewer.gambas?
Exec arguments are an array, additional parameters just need more strings.
Consider this terminal line…
gambas3 /path/myproject
simply..
To provide environment variables use "With"
so terminal would be
env GB_GUI=gb.qt5 gambas3 /path/myproject
gambas Exec syntax….
Posted
Regular

Having trouble with syntax,
Code
Print Exist(User.Home &/ "GambasFolder/Executable/Golf.gambas")
Exec ["gambas3", "GambasFolder/Executable/Golf.gambas"]
The second line produces an error:- "Cannot open a binary file"
Where am I going wrong?
Posted
Guru

Put User.Home in the exec too
Exec ["gambas3", User.Home &/ "GambasFolder/Executable/Golf.gambas"]
oops my mistake i see you are opening a .gambas file with the gambas3 IDE
open the parent folder instead
Exec ["gambas3", User.Home &/ "GambasFolder/Executable"]
or to run the application without a compiled executable try this..
Exec ["gbx3", User.Home &/ "GambasFolder/Executable"]
or to run the executable
Exec ["gbr3", User.Home &/ "GambasFolder/Executable/Golf.gambas"]
You'll want something like this though…
Code (gambas)
Posted
Regular

(I think I may have to have a little lie down now)
b
Posted
Regular

Code
Exec ["gbr3", "GambasFolder/Executable/DocsViewer.gambas"] With ["sTemp=XXX"]
opens "DocsViewer" OK but there is only one args.count.
Shell "gbr3 ~/GambasFolder/Executable/DocsViewer.gambas sTemp=XXXX'" works fine, args.count = 2.
BTW I extract the argument value with Split(Args[1], "=")[1] is there a better way?
Bill
Posted
Guru

Use this …
Code (gambas)
you could use the "With" syntax in your program but should do this…
then this will work…
Exec ["gbr3", "GambasFolder/Executable/DocsViewer.gambas"] With ["sTemp=XXX"]
But it's not advised, it's better to use an argument than an env var
Posted
Guru

bill-lancaster said
BTW I extract the argument value with Split(Args[1], "=")[1] is there a better way?
Yes, use the more advanced Args.class component
/comp/gb.args - Gambas Documentation
Posted
Guru

the following example lets you use multiple filenames as args with or without the -f prefix.
Any arguments that are not handled by Args.Get, Args.Has, etc are considered files to open.
you can use the -f (–file) prefix but you do not need to.
Code (gambas)
- Args.Begin("Title, shows as header when user type --help") ' start processing args
- OpenFileInNewTab(sFile)
1 guest and 0 members have just viewed this.


