[Gambas-user] Args - got it wrong?

Rolf-Werner Eilert rwe-sse at osnanet.de
Thu Mar 8 15:56:27 CET 2018


Am 08.03.2018 um 12:35 schrieb Benoît Minisini:
> Le 08/03/2018 à 12:12, Rolf-Werner Eilert a écrit :
>> Hi folks,
>>
>> Did I get this wrong? Using Args[], I can read commandline arguments 
>> given to the program during start, right?
>>
>> This project is a simple PDF viewer. When I insert this into 
>> Form_Open(), it doesn't run properly. The program shall get the name 
>> of the file to be openend by the calling application:
>>
>>    Select Args.Count
>>    Case 0
>>      TextLabel1.Text = "Keine Datei angegeben"
>>    Case 1
>>      PDFDatei = Args[0]
>>      If Not Exist(PDFDatei) Then
>>        TextLabel1.Text = "??? " & PDFDatei
>>        Return
>>      Endif
>>    Case Else
>>      TextLabel1.Text = "Zu viele Argumente angegeben"
>>      Return
>>    End Select
>>
>> - When I give the name of the file, I get the name of the project.
>> - When I give no argument (no argument in Project...Arguments), I get 
>> the same.
>>
>> It always lands under Case 1 and finds there is no file named "PDF 
>> Viewer".
>>
>> Can you help me here?
>>
>> Regards
>> Rolf
>>
> 
> It's Unix standard : the first argument is always the name used for 
> runnning your program. The real first argument is actually second, and 
> so on.
> 

Ah, ok. Now I found that additionally I have to switch on the argument 
line I want to use. That is Debug/Run With + NOT no argument.

That is for IDE only, isn't it?

Regards
Rolf


More information about the User mailing list