Silverfrost Forums

Welcome to our forums

get_command_argument

1 Feb 2007 9:36 #1597

I have been experimenting with long arguments. The small program below reads an argument and prints it.

  program argtest
  character*160 carg
  call get_command_argument(1,carg,larg)
  write(*,1001)carg

1001 format(a160) stop end

When I run it with an argument of length 150 I get the following 1abcdefghijklmnopqrstuvwx2abcdefghijklmnopqrstuvwx3abcdefghijklmnopqrstuvwx 4abcdefghijklmnopqrstuvwx5abcdefghijklmnopqrstuvwx6abcdefghijklmnopqrstuvwx

When the argument is enclosed in ' ', as it would be if it had spaces, the output is truncated 1abcdefghijklmnopqrstuvwx2abcdefghijklmnopqrstuvwx3abcdefghijklmnopqrstuvwx 4abcdefghijklmnopqrstuvwx5abcdefghijklmnopqrstuvwx6ab

1 Feb 2007 11:25 #1603

Richard,

Have a look at the value of larg. I got 128 and 126 for your 2 cases. It may be that 128 is a limit, although without ' ', the extra characters are also returned.

program argtest character160 carg integer4 larg, status, nchar call get_command_argument (1,carg,larg,status) write(,1001)carg nchar = len_trim (carg) write (,) 'found = ',larg write (,) 'status = ',status write (,*) 'returned = ', nchar 1001 format(a) stop end

2 Feb 2007 8:48 #1604

John,

Yes, I know. I think that 128 is a limit, but the real question is, is this correct Fortran 2003 or a FTN95 bug? Does this mean that in order to parse a command line which has a long argument with spaces, surrounded by ' ', I have to write my own routine?

Richard

2 Feb 2007 12:54 #1605

Yes there is an internal limit of 128 characters. It would be trivial increase this, non-trivial to make it open-ended. Would 256 be enough?

2 Feb 2007 1:34 #1606

Paul,

I imagine 256 should be enough. Long arguments are needed when our clients run our software in very 'deep' project directories. It's quite easy to get past 100 characters, but 200 is really really long. We should really be consistent with Windows, but I have no idea what that entails.

Richard

2 Feb 2007 5:09 #1607

If you want to send me your email address (as a private message) then I will send you a new salflibc.dll when the change has been made.

20 Feb 2007 11:47 #1713

Paul,

Did you get my private message with my email address? When do you expect to have a new salflibc.dll available?

Richard

20 Feb 2007 1:35 #1715

Paul,

Got it, thanks.

Richard

27 Feb 2007 10:42 #1749

Paul,

Although the test program above now prints out the full 150 character argument, in the debugger the full argument is not available and larg is still 126. Unfortunately this means that I cannot easily debug my main program.

Richard

Please login to reply.