ATOI from an array
Jeff Lockyear
Posts: 147
Can someone please tell me why this doesn't work so that I can get on with life?
I'm trying to get around old firmware in an NXI that doesn't support 4-digit XCH commands. This is a distillation of what I've been trying to do. When I look at notifications all I get is SP$00 every time. I've tried assigning the four characters in sChan to 4 separate single CHAR variables, then doing ATOI, then sending it out, but it still doesn't work. I also tried with an NI-2100. Any ideas? At this point I don't even care if the answer makes me look dumb
BUTTON_EVENT [TP,1] { PUSH: { STACK_VAR CHAR sChan[4] sChan = '1556' SEND_COMMAND dvSat, "'SP',ATOI(sChan[1])" SEND_COMMAND dvSat, "'SP',ATOI(sChan[2])" SEND_COMMAND dvSat, "'SP',ATOI(sChan[3])" SEND_COMMAND dvSat, "'SP',ATOI(sChan[4])" } }
I'm trying to get around old firmware in an NXI that doesn't support 4-digit XCH commands. This is a distillation of what I've been trying to do. When I look at notifications all I get is SP$00 every time. I've tried assigning the four characters in sChan to 4 separate single CHAR variables, then doing ATOI, then sending it out, but it still doesn't work. I also tried with an NI-2100. Any ideas? At this point I don't even care if the answer makes me look dumb
0
Comments
Nothing wrong with pulling a single character out of an array, but it's a character (= a single ASCII value) at that point, not a string or char[] like atoi() wants as input. If you were trying to put it in a string, you'd be all set:
sChan = 'test'
SEND_STRING 0, "'character 3 = ', sChan[3]" // outputs "character 3 = s"
But since SP is one of the weird "literal integer" functions, you can use atoi(sChan[1]) or sChan[1]-'0' to get the integer from the ASCII value.
Those "weird" functions that have a single byte integer value for data exist because of the days of AXlink. The fewer characters transmitted, the faster the whole system could run.