call asci programs from unicode program

Just starting out? Need help? Post your questions and find answers here.
User avatar
wichtel
User
User
Posts: 71
Joined: Fri May 02, 2003 11:14 am
Location: Germany
Contact:

call asci programs from unicode program

Post by wichtel »

Hello,
I have a question regarding unicode and ascii.

My program is in unicode, but at one point it calls another exe with RunProgram().
This exe is ascii only.
I need to pass a parameter string, and read the program output and error.
If I compile in ascii it works, compiled in unicode it does not.

I already tried to convert the unicode strings to ascii before I pass them over, but that does not help.
My unicode/ascii conversion works for other parts of the program, so I guess I do soemthing wrong when using RunProgram.

Any ideas?
Thanks
PB 5.40 LTS, W7,8,10 64bit and Mint x64
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: call asci programs from unicode program

Post by ts-soft »

you have to use WriteProgramData() and ReadProgramData()!
you can't use the stringbased functions.

greetings
Thomas
User avatar
wichtel
User
User
Posts: 71
Joined: Fri May 02, 2003 11:14 am
Location: Germany
Contact:

Re: call asci programs from unicode program

Post by wichtel »

Thanks Thomas.
I do that as much as possible.

But how to call the program?
I need to pass the param$ in ascii and read the ReadProgramError() as well.

Code: Select all

   
pid=RunProgram(program$,param$,"",#PB_Program_Hide|#PB_Program_Open|#PB_Program_Read|#PB_Program_Error)
    *deviceinfo=AllocateMemory(1024)
    pok=0
    For p=0 To passwordTimeout
      Delay(10)
      If IsProgram(pid)
        e$=ReadProgramError(pid)
        If e$
           Debug e$
        EndIf   
        If AvailableProgramOutput(pid)
          ReadProgramData(pid,*deviceinfo,1024)
          pok=1
        Else  
          If pok=1
            Break;
          EndIf
        EndIf  
     EndIf    
   Next     
This code works when I compile in ascii.
PB 5.40 LTS, W7,8,10 64bit and Mint x64
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: call asci programs from unicode program

Post by ts-soft »

You have nothing to change on params$!
ReadProgramError() is a problem.
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: call asci programs from unicode program

Post by c4s »

Here is the workaround I'm using right know:
http://www.purebasic.fr/english/viewtop ... 13&t=41952

I posted two feature requests as well:
http://www.purebasic.fr/english/viewtop ... =3&t=41979
http://www.purebasic.fr/english/viewtop ... =3&t=43470 (I probably forgot that I already posted one)
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
wichtel
User
User
Posts: 71
Joined: Fri May 02, 2003 11:14 am
Location: Germany
Contact:

Re: call asci programs from unicode program

Post by wichtel »

Thanks c4s!

So I hit a real problem here...
I'll look at the workarounds and see what I can make of it.
PB 5.40 LTS, W7,8,10 64bit and Mint x64
Post Reply