Page 1 of 1

call asci programs from unicode program

Posted: Tue Nov 16, 2010 3:17 pm
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

Re: call asci programs from unicode program

Posted: Tue Nov 16, 2010 3:20 pm
by ts-soft
you have to use WriteProgramData() and ReadProgramData()!
you can't use the stringbased functions.

greetings
Thomas

Re: call asci programs from unicode program

Posted: Tue Nov 16, 2010 3:30 pm
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.

Re: call asci programs from unicode program

Posted: Tue Nov 16, 2010 4:23 pm
by ts-soft
You have nothing to change on params$!
ReadProgramError() is a problem.

Re: call asci programs from unicode program

Posted: Tue Nov 16, 2010 7:38 pm
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)

Re: call asci programs from unicode program

Posted: Tue Nov 16, 2010 7:51 pm
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.