Why does this work if it doesn't work?
shr00m-dew
Posts: 394
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.
0
Comments
How about this?
LEFT_STRING (DATA.TEXT,(FIND_STRING(DATA.TEXT,max_length_string(DATA.TEXT),1)-1)
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.
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.
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.
Thanks,
Kevin D.