Question

How would you go about doing this?

I have a file which contains roughly 40 lines, each line are variables for an .exe file.
I've setup a foreign command

$ CC := "$something$something:file.exe"

I then try to loop through the file line by line

{Method1}

$ OPEN a file.txt
$ loop:
$ READ/END_OF_FILE:end a b
$ CC b
$ goto loop
$ end:

My problem is because the value of b contains quotes (" ") around it the file.exe does not execute

I also tried to put CC on the start of each line of file.txt (shown below) and run each line 1 at a time just like above but it gives an error that it cannot run CC.exe from the default location. As you can see below variables 2-4 need to be in double quotes if that matters for method 1 ideas.

{Method 2}

$ CC variable1 "variable2" "variable3" "variable4"

What I need to do in the end is run about 10 of these at one time, so i think if I could get method 2 to work that would be the best.

Was it helpful?

Solution

I'm not sure whether I fully understand what you are trying to achieve. From what I read, I would for a text file (file.txt) like

This
That
"Quoted"
"Quoted blank"
" "
This and that
"This and" "that"

write a command procedure (echo.com) like

$ cc:=$sys$disk:[]echo
$ OPEN a file.txt
$ loop:
$ READ/END_OF_FILE:end a b
$ show symb b
$ CC 'b'
$ goto loop
$ end:
$ CLOSE a

which when run gives:

$ @echo
  B = "This"
arg1: 'this'
  B = "That"
arg1: 'that'
  B = ""Quoted""
arg1: 'Quoted'
  B = ""Quoted blank""
arg1: 'Quoted blank'
  B = "" ""
arg1: ' '
  B = "This and that"
arg1: 'this'
arg2: 'and'
arg3: 'that'
  B = ""This and" "that""
arg1: 'This and'
arg2: 'that'
$

where echo.exe is just an simple C program to print argv, starting with argument 1 and quoted with single quotes; and the $ show symb b is just to show what was actually read from the file; the symbols content is quoted with double quotes.

This is more or less what you had, except the $ CC 'b' where the single quotes tells dcl to expand the symbol b. And a close of the input file after reading it is not a bad idea.

No, there is no need to DEFINE anything. For the foreign command you don't have to have the .exe, it's the default.

OTHER TIPS

I was able to get it working by defining CC then using Method 2 in order to call each line

DEFINE CC $something$something:file.exe;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top