pablosavino Posted July 5, 2004 Report Share Posted July 5, 2004 Hi, Im programer for Visual Basic 6, how to send display message from mi application to FS?. please, please, I need an example !!!! tank you sorry, mi inglish is not good. Link to comment Share on other sites More sharing options...
Pete Dowson Posted July 6, 2004 Report Share Posted July 6, 2004 Hi, Im programer for Visual Basic 6, how to send display message from mi application to FS?. Sorry to see you getting no replies. I had hoped some VB programmer would help. I'm no good with VB at all. However, I do know there is a special FSUIPC call invented for writing strings to FSUIPC in VB -- FSUIPC_WriteS. I think this gets around the problem of needing a string pointer ("by reference" instead of "by value"). Isn't that enough to know? What exactly is it you don't understand? As it says in the programmer's guide, you write the string to 3380 (maximum length 128 characters including a zero terminator), and then write a 16-bit (2 byte) value to 32FA to make FSUIPC display it for you. You can do both Write calls (a WriteS then an ordinary Write) before a single FSUIPC_Process call to transfer the stuff to FSUIPC. Regards, Pete Link to comment Share on other sites More sharing options...
jd Posted July 6, 2004 Report Share Posted July 6, 2004 sorry i missed it here is my code snippet: Function adv_disp(Text As String, duration As Long) Dim dwResult As Long Dim j As Long Dim s As String s = Left(Text, 127) s = s & Chr$(0) Call FSUIPC_WriteS(&H3380, Len(s), s, dwResult) j = duration Call FSUIPC_Write(&H32FA, 2, VarPtr(j), dwResult) Call FSUIPC_Process(dwResult) End Function Link to comment Share on other sites More sharing options...
ricardoherrera Posted December 9, 2005 Report Share Posted December 9, 2005 Can anybody help me with the same code in c#, I’m able to do most of the querying, but when it comes to Write, I’m completely lost. I’ve been working on a code, but maybe I’m just destroying my computer :D int dwResult = -1; int token = 14; byte[] bytes; string chars = "Message Text0"; UnicodeEncoding Unicode = new UnicodeEncoding(); bytes = Unicode.GetBytes(chars); fsuipc.FSUIPC_Write(0x3380, chars.Length, ref bytes, ref token, ref dwResult); fsuipc.FSUIPC_Write(0x32FA, 2, ref token , ref dwResult); fsuipc.FSUIPC_Process(ref dwResult); With this code all I can get in FS is the word “M” displayed. (the token =14 is just a number I’m randomly selecting, I know is neither technical nor professional, but that only shows how anxious I am to get this code done) Thanks in advanced for any help, and sorry my English. Link to comment Share on other sites More sharing options...
Pete Dowson Posted December 9, 2005 Report Share Posted December 9, 2005 Can anybody help me with the same code in c# Sorry, I'm afraid I know nothing about C# -- it doesn't look anything like C! But this seem's rather odd: fsuipc.FSUIPC_Write(0x3380, chars.Length, ref bytes, ref token, ref dwResult); fsuipc.FSUIPC_Write(0x32FA, 2, ref token , ref dwResult); Both are calls to FSUIPC_Write, yet the first has 5 parameters and the second has 4. does the C# compiler allow this sort of inconsistency? I've no idea what that token thing is, but you don't appear to have a reference to a value being written in the second Write. I assume 2 is the length, was token supposed to be the value? [LATER] One other thing: string chars = "Message Text0"; UnicodeEncoding Unicode = new UnicodeEncoding(); bytes = Unicode.GetBytes(chars); I don't understand much of that, but: 1) does "bytes" end up holding a string of 8-bit (byte characters), NOT Unicode? If the Unicode value (16-bit) is being sent, then the second (high) byte is probably zero which would end the string, resulting in your 'M'. 2) Is the "0" at the end of "Message Text0" meant to be a zero terminator? It won't be, it will be the character zero. In C strings defined with "" have zero terminators in any case, but these aren't included in the length. If the same applies in C# then your length value needs 1 adding. If the same doesn't apply in C# you need to add the zero byte. In C this would be by \0 or \x00. I don't know if C# has an equivalent way of getting actual values into the string. Regards Pete Link to comment Share on other sites More sharing options...
ricardoherrera Posted December 9, 2005 Report Share Posted December 9, 2005 1) does "bytes" end up holding a string of 8-bit (byte characters), NOT Unicode? If the Unicode value (16-bit) is being sent, then the second (high) byte is probably zero which would end the string, resulting in your 'M'. You where totally right, after reading your post, I started to test with ASCII instead of Unicode (just for testing purposes because honestly I don’t really understand very well the difference or their use for that matter), And it worked (at least that is what it seems) Here is the code.. int dwResult = -1; //Default on FSUIPC C# SDK; int token = -1 ; //Default on FSUIPC C# SDK; string chars = "Message to display"; //String to display byte[] bytes; //Variable where the string is going to be stored once converted to bytes byte MsgTTL; //This variable will hold the time the message is displayed in bytes ASCIIEncoding ascii = new ASCIIEncoding(); int byteCount = ascii.GetByteCount(chars.ToCharArray()); //Variable where the string is going to be stored once converted to bytes bytes = new Byte[byteCount+1]; //Declaring Number of items in byte[] bytes[byteCount] = 0x00; //0 Terminator; bytes = ascii.GetBytes(chars); //Converting the string to byte[] MsgTTL = 10; //Holds the message for 10 Sec. Fsuipc fsuipc = new Fsuipc(); fsuipc.FSUIPC_Write(0x3380, bytes.Length, ref bytes, ref token, ref dwResult); fsuipc.FSUIPC_Write(0x32FA, MsgTTL, ref token , ref dwResult); fsuipc.FSUIPC_Process(ref dwResult); It works for me, but I haven’t tested that much, so if somebody has a suggestion or correction PLEASE Let me know. Thank you Pete very much for your reply, Cya on my next question :lol: Link to comment Share on other sites More sharing options...
Pete Dowson Posted December 9, 2005 Report Share Posted December 9, 2005 fsuipc.FSUIPC_Write(0x3380, bytes.Length, ref bytes, ref token, ref dwResult); fsuipc.FSUIPC_Write(0x32FA, MsgTTL, ref token , ref dwResult); But I still can't fathom how the same call (to FSUIPC_Write) can take 5 parameters in one line and 4 parameters the next. Your C# compiler obviously doesn't care, but how on Earth can the routine that is being called tell which parameter is which? For example, "dwResult" is the 5th parameter in the line to write to 3380 but the 4th in the line to write to 32FA. And what are you actually writing to 32FA? You missed the length, so "10" will be the number of bytes transferred, not the time to be held! And what is this "magic token" for? And why oh why has Microsoft invented a language which appears to bear no relation whatsoever to C and called it C#? Makes no sense to me at all. :-( Sorry. Regards, Pete Link to comment Share on other sites More sharing options...
ricardoherrera Posted December 9, 2005 Report Share Posted December 9, 2005 But I still can't fathom how the same call (to FSUIPC_Write) can take 5 parameters in one line and 4 parameters the next. Your C# compiler obviously doesn't care, but how on Earth can the routine that is being called tell which parameter is which? For example, "dwResult" is the 5th parameter in the line to write to 3380 but the 4th in the line to write to 32FA. Sorry Pete, I missed this part. Actually the function FSUIPC_Write is defined 5 different ways on the fsuipc.cs file in the SDK: FSUIPC_Write(int dwOffset, byte param, ref int Token, ref int dwResult) FSUIPC_Write(int dwOffset, short param, ref int Token, ref int dwResult) FSUIPC_Write(int dwOffset, int param, ref int Token, ref int dwResult) FSUIPC_Write(int dwOffset, long param, ref int Token, ref int dwResult) FSUIPC_Write(int dwOffset, int dwSize, ref byte[] param, ref int Token, ref int dwResult) So, you can use any of the 5 above: (I used the fifth one for 0x3380 and the first one for 32FA). And what are you actually writing to 32FA? You missed the length, so "10" will be the number of bytes transferred, not the time to be held! I wish I can have a valid answer, but awesomely enough that is the only value that when I pass gives me the time I want (in seconds) for the message to be displayed And what is this "magic token" for? I think that if you cannot answer that question yourself then I’m the last person on hearth to be able to answer it. The C# example that is on the SDK comes with it defined globally for all the functions within the application assigned as token = -1, and all the functions to set or get values use the same token. Going over the fsuipc.cs file I found a definition of Token as: “Contains the unique identifier token used to Get the value”; At the moment is all I can sai about it. Sorry. And why oh why has Microsoft invented a language which appears to bear no relation whatsoever to C and called it C#? Makes no sense to me at all. Sorry. I guess is all about the money :D Sorry I can’t be helpful; to be honest this is my first C# program ever as a matter of fact mi first program ever. Thank you again, an thank you also for this beautiful piece of work --> FSUIPC Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now