Passing an argument from Filemanager to a Gambas-App
Posted
#1
(In Topic #743)
Regular

In a filemanager (i.e. KDE/Dolphin) I want to right-click an image. The context menue appears and I want to start my Gambas fileviewer-app to open and view the selected file. The filemanager opens my coded Gambas-fileviewer-app in the background passing just a single argument (path/filename as string) to the app.
Unfortunately, Gambas arguments require two dashes "–" upfront and that's why
Code
Application.Args[1-n]
Posted
Regular

I would have thought you could just start your Gambas program with something like: myImageViewer filename
…and then read the filename from Application.Args[0] in your code.
Posted
Regular

Posted
Guru

Posted
Regular

I modified some code to test it:-
Code (gambas)
- strThumbNail = LibRAW.ExtractSingleThumbnail(RAW_FILE_NAME)
I also modified "Open With..." properties in the file manager so it always loads my program if I double click on a RAW file type …but you may want to chose each time.
Posted
Regular

Code
Public Sub Form_Open()
Dim myFile As Variant
If IsNull(Application.Args[1]) Then
Message("No Argument")
Quit
Else
myFile = Val(Application.Args[1])
Endif ' Application.Args
message("arg0: " & Application.Args[0] & gb.NewLine & "arg1: " & myFile & gb.NewLine & "arg2: " & Application.Args[2])
EndI found out that arg[1] is empty because the function val() destroys obviously the string. When I replace
Code
myFile = Val(Application.Args[1])Code
myFile = Application.Args[1]
1 guest and 0 members have just viewed this.



