Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Msg = Left(Msg, 127)

Msg = Msg + Chr$(0)

If Argumente.Sim = False Then Exit Sub

result = FSUIPC_Write(&H3380, Len(Msg), VarPtr(Msg), dwResult)

result = FSUIPC_Write(&H32FA, 2, VarPtr(mode), dwResult)

result = FSUIPC_Process(dwResult)

The code above should show a text in the FS2004 window but it does not - only 4 garbage characters are shown.

Can anybody help me ?

Posted

The code above should show a text in the FS2004 window but it does not - only 4 garbage characters are shown.

Is your string in ASCII? FS uses straight ASCII strings, one byte = one character, with a zero terminating byte. The only previous time anyone had the problem you describe was because he was compiling with something set to give 16 bit (wide or Unicode) characters. I don't know VB at all, but that is probably your problem.

Regards,

Pete

Posted

May be the problems come from Unicode.

The OS is Win2000 SP4

i tried to convert the msg-string with the StrConv-function

But the parameters "vbfromUnicode" and "vbUnicode" didn't change anything. Only the garbage looked different.

Posted
May be the problems come from Unicode.

The OS is Win2000 SP4

I use both Win2000 and XP, makes no difference. FS still works with straight ASCII for these things.

i tried to convert the msg-string with the StrConv-function

But the parameters "vbfromUnicode" and "vbUnicode" didn't change anything. Only the garbage looked different.

They sound like the wrong functions. It sounds like there's a "VB format" and Unicode, neither of which are correct. I expect VB is "wide character" if not specifically Unicode. Use your debugger and see what the actual data looks like. If every other byte is zero, it is the wrong format.

Sorry, I don't know VB. You'd need to look up how to convert whatever it is VB is using into standard ASCII text. It must be a common requirement. Most of the world's software still uses standard ASCII for so many things.

Regards,

Pete

Posted

This works here, just plop it in and use it...

Public Sub MessageToFS(MessageString As String)

'send visible message to FS!

Dim sString As String

sString = MessageString & vbNullString

FSUIPC_WriteS &H3380, 128, sString

FSUIPC_Write &H32FA, 2, 20 'will display for 20 seconds

End Sub

Posted

result = FSUIPC_Write(&H3380, Len(Msg), VarPtr(Msg), dwResult)

result = FSUIPC_Write(&H32FA, 2, VarPtr(mode), dwResult)

result = FSUIPC_Process(dwResult)

Ah, thanks to James, yes, I spot the error here. The first FSUIPC_Write above needs to be an FSUIPC_WriteS (for Write String). I forgot, VB is a bit weird with passing strings -- C and C++ pass the pointer, VB doesn't unless you force it to. Or something like that.

As James' code snippet also shows, you still need to add a zero at the end -- it seems VB strings unlike C/C++ ones aren't stored naturally with terminating zeroes.

Thanks James!

Pete

Posted

Oopsy, sent you the wrong code, this is the correct one:

Public Sub MessageToFS(MessageString As String)

'send visible message to FS!

Dim dwResult as Long

Dim sString As String

Dim sDelayTime as Long 'will display for 20 seconds

sString = MessageString & vbNullString

If FSUIPC_WriteS(&H3380, 128, VarPtr(sString), dwResult) and FSUIPC_Write(&H32FA, 2, VarPtr(sDelayTime), dwResult) Then FSUIPC_Process (dwResult)

End Sub

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.