Please help me to execute shell program to call a scanner

jothis

Active Member
Licensed User
Dear Sir,
I have a program to scan. I use a third party software - Accquire
So they give me some suggestion to scan.
To Scan from a particular Scanner, I need to use this command.
for eg: I have a scanner named HP PSC 1400 TWAIN.

So To run in Command line, they told me that use below command.
c:\>acquire /s="HP PSC 1400 TWAIN"

They told me that we need to specify Quotes because, Scanner name has spaces.

Now I need to bring same program to basic4ppc.

so the code is given below

wpgm="C:\Acquire\Acquire.exe"
wpar="/s=" & " " " & "HP PSC 1400 TWAIN" & " " "
Shell(wpgm, wpar)


But I got error.


I know the line wpar="/s=" & " " " & "HP PSC 1400 TWAIN" & " " "
is not correct.

I got error is like, Too many filenames 1400. I think program detect HP and PSC and 1400 like instead of single "HP PSC 1400 TWAIN"

How I can write this code with scanner name inside qutoes ?

Can you help me please how I can write this program well.

jothis
:sign0085:
 

Attachments

  • 01.sbp
    400 bytes · Views: 216
Last edited:

mjcoon

Well-Known Member
Licensed User
...How I can write this code with scanner name inside quotes ?

I agree that Basic4PPC should have some "escape" mechanism for including quotes in a literal string such as "\"".

But it doesn't so you have to use "Chr(34)" so your example has to be:
B4X:
wpar="/s=" & Chr(34) & "HP PSC 1400 TWAIN" & Chr(34)

Mike.
 

jothis

Active Member
Licensed User
Hi Mike,

I don't know I how say thanks to you. Any way IT WORKS NOW.

Many many thanks to you.

:sign0060::sign0060::sign0060:
Regards
Jothis.
 

Skrobel

Member
Licensed User
Sorry for refreshing this thread but I have a similar problem.

I want to make an ImageButton which triggers the new SMS dialog on my device. So I want to execute the tmail.exe with following arguments:
-service "SMS" -to ""
Unfortunately the quotes have to be there.
Using the advice from above I wrote:
B4X:
Sub SMSButton_Click
   Shell ("\windows\tmail.exe", "-service Chr(34)SMSChr(34) -to Chr(34)Chr(34)")
End Sub

But it doesn't seem to do anything after compiling and movig to device.
When I change the executable into \Windows\Reset.exe without any arguments the same Button works like a charm, so It has to be a fault of the arguments.
Should the Chr(34) work the same way on the device that it seems to work on Desktop?
 

Skrobel

Member
Licensed User
Man, you are fast :)

However the compiler says there is an error "Length cannot be less than zero" Occured in this line.
In the program the last bracket is marked brown so I think the last quote is treated as starting not ending quote. I tried some experimenting with removing/adding quotes but there's no big difference...

Thanks for your help :)
 

Skrobel

Member
Licensed User
Haha!
I thought this one is the most important and therefore didn't try to remove it :)

This time it works! Thanks a lot :D

I wonder of one more thing:
If I would put the "path" and "arguments" as Strings in registry would I still have to use the & Chr(34) & to make the application run? Or this is only a matter of the compiler which doesn't know what to do with multiple quotes?

I thought of making my app more "flexible" and therefore let user to manually change the path and parameters into whatever anyone would want to. The easiest way to do it would be to store the paths in a config.ini file or in registry. But would it work without Chr(34)?
 

klaus

Expert
Licensed User
Longtime User
You'll need the Chr(34) evrey time you want to generate a string.

Example:
path = "\windows\tmail.exe"
argument = "-service " & Chr(34) & "SMS" & Chr(34) & " -to " & Chr(34) & Chr(34)
here you need the Chr(34) !

Then
Shell(path,argument)

If you save 'argument' to a file and read it back you don't need any Chr(34).

Best regards.
 
Top