Command line parameters

Hi All,
Having difficulty getting the variables correct on the RUN command.
Running Tesseract from the command line.
THIS DOES WORK:
run(‘tesseract C:\B\3-reg.jpg c:\B\aa_3’,1)
where the first parameter is the input file
second parameter is the output text file.

I want to use VARIABLES for the file names - all variables are cstrings in the following example:

infilename = 'C:\B\3-reg.jpg'
savefilename = 'C:\B\aa_3'
tcommand  =  infilename & ' ' & savefilename
run('tesseract tcommand',1)

However, this does NOT EXECUTE and tesseract does not run.

So, I have the coding of the command line incorrect using variables. I have tried multiple permutations. I am sure that someone can help me get the correct command line for using the variables for input and output files.
Thanks,
Ron

FYI: I just pasted what you wrote to ClarionAssistant and that was the reply - I already knew the answer just wanted to see what CA would say.

Kevin, the issue is that you're passing the string 'tesseract tcommand' as a 
literal—single quotes don't interpolate variables. You need to concatenate the 
variable into the command string.

Change this:
clarion
run('tesseract tcommand',1)

To this:
clarion
run('tesseract ' & tcommand, 1)

Or build the full command first:
clarion
tcommand = 'tesseract ' & infilename & ' ' & savefilename
run(tcommand, 1)

The & operator concatenates the values are actually included in the 
command that gets passed to run(). Single quotes create a literal string; to 
embed variable values, you created.

Hi Kevin,
run('tesseract ’ & tcommand,1)
Yes, that did it. HELP was not very useful. Thanks for the explanation as well.
Thanks,
Ron

Ron,
If there is any chance there might be a space in the file name or path you need to double quote the parameters.

infilename = 'C:\B\3-reg.jpg'
savefilename = 'C:\B\aa_3'
tcommand  =  '"' & infilename & '" "' & savefilename & '"'
run('tesseract ' & tcommand,1)

Hi Rick,
Thanks for that - right now, I can control the file names and no spaces. But now I am ready if some filenames come to me with spaces.
Thanks,
Ron

If you are not using ClarionAssitant you are missing out on a wonderful resource - John Hickey and his team have done a wonderful job. it has a full knowledge base of clarion, NetTalk, Noyantis and many other 3rd party products and answers you with full knowledge of them. and what it can do w/in the ide is amazing.

Can I use ClarionAssistant with my ChatGPT subscription or do I need Claude?

Best regards
Jeffrey

That means I need another subscription. Hmm, why no ChatGPT subscription support…

Best regards
Jeffrey

Ask John Hickey :slight_smile:

Kevin

C-415.819.1415
Communication is the key to a successful relationship.

To run commands properly they need to be encapsulated with double quotes when a space is used in the file path to the program and any command line switches.
eg

"driveletter:\path\to\tessteract" "-switch with spaces"
"driveletter:\path\to\tessteract.exe" "-switch1 with spaces -switch2 without"
"driveletter:\path\to\tessteract.exe" "-switch1 with spaces" "-switch2 without"

To test if your output to run works, open a cmd or powershell window and paste what you send to Run() to the command line. If runcommand wont run in a cmd/dos window or in powershell, the command still isnt right.

root@DESKTOP-MVKOR9S:~# z:\bin\args.exe "foo bar"

If you dont include the file path for tesseract, add it to the Windows Path environment variable.

The API parameter [in, optional] lpApplicationName explains the need for double quotes.

I also assume you have taken care of UAC elevation?

John responded on Discord:

Yes it does support ChatGPT, just go to Settings and under Launch choose Codex as your Backend. You should also choose your Plan as well. Let me know if you have any issues!