View Full Version : can i put reg value to sendmessage plugin?
Ron
October 13th, 2002, 03:55 PM
I'll look into the sendmessage [reg] stuff,.. the AND/XOR stuff is also possible but writing a parser is pretty difficult. If anyone knows how to go about that i'd like to know how to do it :)
Ron
October 13th, 2002, 03:55 PM
Hi Mike,
It would be great if you wanted to give this a try. And about the parser,.. what you now describe a the 'easy' part, this is done in Girder in the compare action.
Also the replacement of a register in a strings is automatic already.
Thus : [reg1] or [reg 1] is automatically replaced by girder to the value in there by a function called : PCHAR ParseRegString(PCHAR in)
But its gets tricky when you can add OR /AND and multiple [regX] then you have to have some smart way of doing things cause
( ( [reg1]==0 AND [reg3]==1 ) OR [reg4]!=5 ))
doesn't seem like a trivial thing to parse :D
Let me see if I can get the sendmessage converted.... You'll hear more on this later today.
Ron
Ron
October 13th, 2002, 03:55 PM
Hmm that was rather painless,.. i've release SendMessage 1.5 this includes the much :D requested [regX] support. See the included .gir file. Let me know of any problems.
Warning NOT compatible with original sendmessage.
Ron
October 13th, 2002, 03:55 PM
Alway nice to learn new stuff,.. if you know of a good reference let me know. Btw the registers are implemented as an Array[1..5]. Yeah i know,.. pascal... :( But we can also make the parser in an plugin (C/C++).
That would be a neat feature. Todo for today: Playlist in GMP
mterlouw
October 13th, 2002, 03:55 PM
I don't think you can. I'd like to do that too, because the Generic Remote Control Interface for the ATI All-In-Wonder TV Tuner supports jump-to-channel via SendMessage commands. You have to put the channel in wParam, so it would be really great if I could set wParam to [reg1] and have Girder substitute the register contents when the message is sent. I tried this and like you said, it doesn't work.
Would it be too hard to implement this Ron? I was going to check out the source for the SendMessage plugin, but the link is down (on your developer's page). I've never coded a dll, but maybe I could modify it to work if I could get the source.
While I'm requesting features (just tell me to shut up when I go to far ;) have you thought about adding logical operations to the registers? If we had AND, OR, and XOR, as well as their equivilents in the Check Register command, it would be easier to implement flags.
Thanks for your time.
Mike
mterlouw
October 13th, 2002, 03:55 PM
Agreed coding a parser is a pain in the ass. Basically what you do is define a way for your parser to know what kind of data it is reading. The simplest parser you could use for this would accept only one item on the line. This item would be either a numerical value or a register. The parser determines what is there by the first character on the line. If the first character is a digit, then you can assume it's a number; if the first character is '[' then you can assume it's a register.
In the former case you can then read in the number one digit at a time. Hex numbers are easy because you don't have to do much conversion, just a lookup if it's an alpha char (A-F). Decimal numbers (base-10) are a little more involved. The way I did it was use an incremental multiply algorithm. You start with the last character, multiply the next char to the left by 10 and add it to the first, multiply the number to the left of that by 100 and add it to the previous result, and so on. This is just one way to do it; I'm sure there's others.
For registers all you have to do is verify that the text follows the pattern [regX] where X is the register number. Then you just substitute the requested register for the result.
As I mentioned before I'm willing to give this a try. All I really need is the source for the SendMessage plug-in and a makefile. I currently have Borland's free compiler as well as DJGPP installed on my system so if you have a makefile for one of those compilers that would be cool. I can try to make this backwards-compatible with the current SendMessage plug-in as well (I assume all this means is have it use the same entries in the .gir and .gxr files). I should be able to figure out how to get to the regs by checking out how the current plugin saves the results to a register.
If you have any questions or if you want me to give it a try please don't hesitate to contact me.
Mike
[Edited by mterlouw on 04-20-2001 at 09:44 PM GMT]
mterlouw
October 13th, 2002, 03:55 PM
Cool I look forward to seeing what you come up with. It sounds like what you're describing is an expression evaluator. These are of course harder to code. I have made one before for an assembler I was writing.
To go about this you need to break up the line into 'tokens', which are possibly handled best in C with a linked list. Every expression follows the pattern of VALUE - OPERATOR - VALUE - OPERATOR - VALUE give or take more values/operators. The only exception to this is if you allow a negative number to come first in the expression which would put an operator first on the line. A little check can be done to resolve that situation.
Also if you support parenthesis you will need to make special tokens for open and close parenthesis. After the expression has been parsed you can then go about solving the component expressions. Search from left to right for the first close-parenthesis. Then everything between that point and the previous open-parenthesis can be solved. You have to establish an order of precidence for the operations and make sure you stick to that order. When done you replace the parenthesis and everything in between with the result. Now you continue scanning for the next close-parenthesis and repeat the cycle until the expression is solved.
Yes, this is a lot of work. It's worthwhile if it's something you would like to learn, but not necessary unless you want to make Girder a really hard-core programmable app. When I suggested the logical operations, I was thinking more like commands such as "AND register to register" and let the Check Register command handle things like "[reg1] && [reg2]". I don't know how your current source looks, but you should be able to implement this with just a few added lines. Again don't let me tell you how to write your program ;)
Anyways thanks again for all the feedback Ron. If you want to go ahead with the expression evaluator I'd be happy to offer further advice or even help with the implementation, but good luck either way. I may even be able to dig up my old source code, but I don't know if I even have it anymore. It was written in 16-bit assembler, BTW.
Well I'd better close. I'm getting in the habit of writing rather long messages here :) Talk to you soon!
Mike
mterlouw
October 13th, 2002, 03:55 PM
Wow! You snuck that one out while I was typing the last message. You are awesome!
sansan
October 13th, 2002, 03:55 PM
maybe it's in FAQ, but I didn't find it...
I want to control winamp. It works very well via sendmessage plugin. I can get know what track is playing now, how many tracks in playlist, etc. And I like it.
Now I want to make my digit keys on remote working. I have "+10" key and "0" - "9" keys. So I can write sequense of actions that will construct any wanted number ("+10" + "+10" + "+10" + "8" = 38), and I want to send this number to winamp in message. But i need to use register for that. Can I use register value to insert it in SendMessage plugin? And how? I try to write [reg2] in WParam of SendMessage plugin, but it doesn't work. And when I open this window again, string "[reg2]" disappears and there is "0" in WParam string =((
[Edited by sansan on 04-18-2001 at 09:14 AM GMT]
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.