Question about compare strings
ondrovic
Junior Member
is there a way to compare multiple strings?
I guess what i am saying is if char is between char1 & char 2 do something if no do something else
Or is there a better way
If(char => Compare_String(char1,Char2) && var <= Compare_String(char3,char4)
{
do something
}
Else
{
do something
}
I guess what i am saying is if char is between char1 & char 2 do something if no do something else
Or is there a better way
Comments
-
Never mind!
-
Your example is kind of confusing and inconsistent with your question, so I'll just answer your question.
I'd compare the strings with the typical comparison operators < > == <>. Compare_String seems useless unless you want to use the ? wildcard, in which case it would be helpful. Highlight compare_string in your code and hit F1 for details.
What you want isIf((char >= char1 && char <= char2) || (char >= char2 && char <= char1)) // I'm not going to assume char1<char2 { //do something (in between) } Else { //do something (not in between) }I haven't actually tried to do this in NetLinx but it should work. If it doesn't then TYPE_CAST all these chars to INTEGER and it will definitely work. -
Your example is kind of confusing and inconsistent with your question, so I'll just answer your question.
I'd compare the strings with the typical comparison operators < > == <>. Compare_String seems useless unless you want to use the ? wildcard, in which case it would be helpful. Highlight compare_string in your code and hit F1 for details.
What you want isIf((char >= char1 && char <= char2) || (char >= char2 && char <= char1)) // I'm not going to assume char1<char2 { //do something (in between) } Else { //do something (not in between) }I haven't actually tried to do this in NetLinx but it should work. If it doesn't then TYPE_CAST all these chars to INTEGER and it will definitely work.
Thanks Matt I will give that a try -
so here is what I have but it doesn't seem to be working correctly
If((sWeather.Time > sWeather.Sunset) && (sWeather.Time < sWeather.Sunrise)) { sWeather.Icon = "sWork,'n.png'" } Else { sWeather.Icon = "sWork,'d.png'" } sWeather.Time = 8:45 PM sWeather.Sunset = 8:34 PM
Any ideas why the file isn't updating correctly? -
If your going to do < or > comparisons of time I would make a function that first converts time to seconds based on 24 hour time. Then just compare the interger values or long values. Or you could do seperate atoi(hour) and atoi(minutes) comparisons.
-
If your going to do < or > comparisons of time I would make a function that first converts time to seconds based on 24 hour time. Then just compare the interger values or long values. Or you could do seperate atoi(hour) and atoi(minutes) comparisons.
Actually > and < work just fine this way. No need to do anything else. I do agree the time should be adjusted to 24 hour time.
IF (TIME > '01:00:00' and TIME < '13:00:00')
{
} -
AMXJeff wrote:
Actually > and < work just fine this way. No need to do anything else.
Ya know, that would never had occurred to me that the decimal or binary equivent of ascii time would be sequentally greater too. I don't think I could do it that way though since the concept hurts my brain but maybe in time I can adapt and think more like a programmer who views everything as numbers. -
AMXJeff wrote:
Actually > and < work just fine this way. No need to do anything else.
Ya know, that would never had occurred to me that the decimal or binary equivent of ascii time would be sequentally greater too. I don't think I could do it that way though since the concept hurts my brain but maybe in time I can adapt and think more like a programmer who views everything as numbers.
That's been an old programmers trick for some time. It just so happens that using a comparison like this is actually comparing the hex ascii value of the character which happens to work.
Somehow, I still don't like to do it. My main code always contains a little routine that converts the current time into decimal integer (seconds of the day. ex: 10,800= 3:00 AM)
I also convert the calendar day to Julian. It just makes creating and managing anything that schedules a lot more reliable and far fewer logic statements. -
AMXJeff wrote:
Actually > and < work just fine this way. No need to do anything else.
Ya know, that would never had occurred to me that the decimal or binary equivent of ascii time would be sequentally greater too. I don't think I could do it that way though since the concept hurts my brain but maybe in time I can adapt and think more like a programmer who views everything as numbers.
One should note, the reason this works is because the format returned by TIME has leading zeros. Otherwise, 2:00:00 > 11:00:00, etc.
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums
