Why does this work if it doesn't work?
shr00m-dew
Junior Member
Ok, caller-ID from a modem. Data_event is
DATE = XXXX
TIME = XXXX
NMBR = XXXXXXXXXX
NAME = XXXXXXXXXXXXXXX (up to 15)
All lines have carriage return, line feed after them.
Here's the code:
Loop sets positions 1-9 to 2-10. The assignment should left_String everything up to the position before the carriage return. Problem comes when the name assignment is less then 15 characters. .CID_NAME max length is set to 15. Everything else is a fixed length coming in. I guess none may be working correctly, I'm just not seeing it since date, time, and number are always equal to the assigned max length.
If the name appears as 15 characters, or less then 15 with spaces equal to 15, it works fine. If the name comes in as less then 15 characters I'm still getting the 13,10 tacked onto the end. I may be looking at it wrong, but shouldn't the find_string return the position of the 13, and then the left_String take everything up to one position before the 13?
I'm testing CID[1].CID_NAME=LEFT_STRING (DATA.TEXT,(FIND_STRING(DATA.TEXT,"13",1)-1)) but I have to wait until someone calls with a short name. You would think that if something was going wrong left_string wouldn't return anything because find_String would be zero.
Kevin D.
DATE = XXXX
TIME = XXXX
NMBR = XXXXXXXXXX
NAME = XXXXXXXXXXXXXXX (up to 15)
All lines have carriage return, line feed after them.
Here's the code:
IF (FIND_STRING (DATA.TEXT,'DATE',1))
{
FOR (LOOP=9 ; LOOP>=1 ; LOOP--)
{
CID[LOOP+1]=CID[LOOP]
}
REMOVE_STRING (DATA.TEXT,'DATE = ',1)
CID[1].CID_DATE=LEFT_STRING (DATA.TEXT,(FIND_STRING(DATA.TEXT,13,1)-1))
REMOVE_STRING (DATA.TEXT,'TIME = ',1)
CID[1].CID_TIME=LEFT_STRING (DATA.TEXT,(FIND_STRING(DATA.TEXT,13,1)-1))
REMOVE_STRING (DATA.TEXT,'NMBR = ',1)
CID[1].CID_NUMBER=LEFT_STRING (DATA.TEXT,(FIND_STRING(DATA.TEXT,13,1)-1))
REMOVE_STRING (DATA.TEXT,'NAME = ',1)
CID[1].CID_NAME=LEFT_STRING (DATA.TEXT,(FIND_STRING(DATA.TEXT,13,1)-1))
Loop sets positions 1-9 to 2-10. The assignment should left_String everything up to the position before the carriage return. Problem comes when the name assignment is less then 15 characters. .CID_NAME max length is set to 15. Everything else is a fixed length coming in. I guess none may be working correctly, I'm just not seeing it since date, time, and number are always equal to the assigned max length.
If the name appears as 15 characters, or less then 15 with spaces equal to 15, it works fine. If the name comes in as less then 15 characters I'm still getting the 13,10 tacked onto the end. I may be looking at it wrong, but shouldn't the find_string return the position of the 13, and then the left_String take everything up to one position before the 13?
I'm testing CID[1].CID_NAME=LEFT_STRING (DATA.TEXT,(FIND_STRING(DATA.TEXT,"13",1)-1)) but I have to wait until someone calls with a short name. You would think that if something was going wrong left_string wouldn't return anything because find_String would be zero.
Kevin D.
Comments
-
Hey Kevin how's it going?
How about this?
LEFT_STRING (DATA.TEXT,(FIND_STRING(DATA.TEXT,max_length_string(DATA.TEXT),1)-1) -
You could be asking for too much
LEFT_STRING will return everything it can if FIND_STRING returns 0 because you?ll be asking for a left string of 0-1 which is a really big number (65535.) I don?t know if this is the culprit behind your problems but this is a potential candidate.You would think that if something was going wrong left_string wouldn't return anything because find_String would be zero. -
Hey Kevin how's it going?
How about this?
LEFT_STRING (DATA.TEXT,(FIND_STRING(DATA.TEXT,max_length_string(DATA.TEXT),1)-1)
Going well.. Just about done with this job.
Did you mean something like this:
LEFT_STRING (DATA.TEXT,(max_length_string(DATA.TEXT)-2)) ?
Take everything remaining, minus the last two characters (carriage return and line feed)? Since the name is the last item, that would work.. Still curious why the first doesn't.
Kevin D. -
Joe Hebert wrote: »LEFT_STRING will return everything it can if FIND_STRING returns 0 because you?ll be asking for a left string of 0-1 which is a really big number (65535.) I don?t know if this is the culprit behind your problems but this is a potential candidate.
Now that would make since. Since the first three are fixed, it just fills up the array disreguarding the carriage return and line feed (and the rest of the data). The name array could have more slots then characters available so I get it all.
So that points to find_String needing an actual character in quotes and not just the decimal equivalent. Hopefully the find_String (data.text, "13", 1) works.
Kevin D. -
Adding double quotes around the carriage return has done the trick!
Thanks,
Kevin D.
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