Page 1 of 1

[430b5]Problems with ReadProgramString()

Posted: Thu Dec 04, 2008 7:23 pm
by harff182
moin, moin...

I have compiled this for console:

Code: Select all

If OpenConsole()
  title.s = ""
  Repeat
    title + ProgramParameter()
  Until ProgramParameter() = ""
  
  PrintN("data = start")
  PrintN("title = "+title)
  PrintN("otitle = The silence of the lambs")
  PrintN("year = 1990")
  PrintN("country = USA")
  PrintN("regie = Jonathan Demme")
  PrintN("mmactor = Anthony Hopkins")
  PrintN("mfactor = Jodie Foster")
  PrintN("fsk = 16")
  PrintN("len = 108")
  PrintN("type = feature movie")
  PrintN("genre = psycho-thriller")
  PrintN("data = end")
  Delay(5000)
  CloseConsole()
 EndIf
End
Now I call it this way:

Code: Select all

hProcess = RunProgram("plugin.exe","Das Schweigen der Lämmer","",#PB_Program_Open|#PB_Program_Read|#PB_Program_Hide)
  If hProcess
    Debug "No something should appear..."
   
    Repeat
      Debug ReadProgramString(hProcess)
    Until ProgramRunning(hProcess) = #False
    
    CloseProgram(hProcess)
  EndIf
 
End
I get debugged:
No something should appear...
d
t
o
y
c
r
m
m
f
l
t
g
d
What am I doing wrong?

TIA...
scholly

Posted: Thu Dec 04, 2008 7:29 pm
by Trond
I bet the first program is compiled with unicode on, the other one with unicode off.

Posted: Thu Dec 04, 2008 7:36 pm
by harff182
Arrrrgl... :oops:

Image How did you know so fast?
It was the other way around.

Thx...
scholly

Posted: Thu Dec 04, 2008 9:25 pm
by Trond
When only the first character arrives it's a classical unicode problem. It's because of the unicode storage format with 0 bytes as part of low characters. In ascii mode, this 0 byte means the string should terminate there and then.

Posted: Thu Dec 04, 2008 10:41 pm
by harff182
Thanks.
I like to learn new things this way, as I shurly will not forget this "problem" of my code and the solution.