PDA

View Full Version : gir_compare



RobRoy
December 2nd, 2002, 08:23 AM
In my plugin I need to have a value tolerance in the eventstring I receive!

Example : if the learned string in Girder is 205.66.35.99.87.54 and when I press the same button again a receive the same string or a string a little different 206.35.98.87.56 or 205.68.35.97.85.54. I want to use the function int gir_compare(pchar orig, pchar recv);

Can someone could explain me exactly how the function is working? and If that possible to do what I when to do with this function?

SteveV
December 3rd, 2002, 03:59 AM
The function simply checks whether or not both strings are equal, returns true if they are and false if they're not. You'll need to do some additional work if you're trying to determine if the values are approximately the same.

Perhaps you can break the string into substrings at the "." Convert the substings into numbers and that check each group of numbers is within some predetermined +/- range, and return true or false as appropriate.

Good luck -- Steve

RobRoy
December 3rd, 2002, 07:01 AM
The function simply checks whether or not both strings are equal, returns true if they are and false if they're not.

I know that I compare the string that a receive with a another string but what is that string? How can I compare my string with the string already learned in Girder? I think that I'm missing something to understand.

Thank!

Mark F
December 3rd, 2002, 07:24 AM
I think you have the process a little bit mixed up. :)

First, you pass the event string from your device to Girder. Then Girder will try to match this event string to any event strings it has learned from your device. During the matching process, Girder calls gir_compare() multiple times and passes in the two strings that you must compare.


int gir_compare(pchar orig, pchar recv);

You determine if they are "equal" by whatever means needed.

The heuristics you want to apply are NOT done prior to passing the event string to Girder. You apply them during the event string matching process.

Does this make more sense?

RobRoy
December 3rd, 2002, 07:29 AM
Yes that make a lot more sense! Thank your for your clear answer.