program echo_command_line integer i, cnt, len, status character c*30, b*100 call get_command (b, len, status) if (status .ne. 0) then write (*,*) 'get_command failed with status = ', status stop endif write (*,*) 'command line = ', b (1:len) call get_command_argument (0, c, len, status) if (status .ne. 0) then write (*,*) 'Getting command name failed with status = ', status stop end if write (*,*) 'command name = ', c(1:len) cnt = command_argument_count() write (*,*) 'number of command arguments = ', cnt do i = 1, cnt call get_command_argument(i, c, len, status) if (status .ne. 0) then write (*,*) 'get_command_argument failed: status = ', status, ' arg = ', i stop end if write (*,*) 'command arg ', i, ' = ', c(1:len) enddo write (*,*) 'command line processed' end If the above program is invoked with the command line " echo_command_line.exe -o 42 -a hello b", the following is displayed: command line = echo_command_line.exe -o 42 -a hello b command name = echo_command_line.exe number of command arguments = 5 command arg 1 = -o command arg 2 = 42 command arg 3 = -a command arg 4 = hello command arg 5 = b command line processed |