WRITE FILE INDEX ISSUE
mjones2620
Posts: 86
HELP!
This may take a few passes through to figure out what I'm trying to accomplish.. but essentially I am trying to write to a structure that has a max legnth of 36. This works perfectly when booking a room, but for whatever reason the write file function extends the length of the cSUBJECT in the structure to 16 after each pass. I can't figure out why for the life of me.
This may take a few passes through to figure out what I'm trying to accomplish.. but essentially I am trying to write to a structure that has a max legnth of 36. This works perfectly when booking a room, but for whatever reason the write file function extends the length of the cSUBJECT in the structure to 16 after each pass. I can't figure out why for the life of me.
PROGRAM_NAME='Calendar Demo Rev 1' (***********************************************************) (* FILE CREATED ON: 01/16/2015 AT: 08:00:17 *) (***********************************************************) (* FILE_LAST_MODIFIED_ON: 01/29/2015 AT: 11:14:13 *) (***********************************************************) DEFINE_DEVICE dvMaster = 0:1:0 dvTP = 10001:1:0 dvTP_Locked = 10001:3:0 dvTP_Mtg = 10001:4:0 (***********************************************************) (* CONSTANT DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_CONSTANT MAX_USERS = 500 MAX_MEETINGS = 36 TL_FEEDBACK = 1 TL_FEEDBACK2 = 2 TL_FEEDBACK3 = 3 (***********************************************************) (* DATA TYPE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_TYPE STRUCTURE _sUSERS //Presets Structure { CHAR cID[15] CHAR cFIRST_NAME[25] CHAR cLAST_NAME[25] CHAR cEMAIL[50] } STRUCTURE _sMTG //Mtg Structure { CHAR cHOST_NAME[25] CHAR cSTART_DATE[25] CHAR cSTART_HOUR[4] CHAR cSTART_MINUTE[4] CHAR cEND_HOUR[4] CHAR cEND_MINUTE[4] CHAR cSUBJECT[50] } (***********************************************************) (* VARIABLE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_VARIABLE PERSISTENT _sUSERS uUSERS[MAX_USERS] PERSISTENT _sMTG uMTG[MAX_MEETINGS] VOLATILE CHAR cDATA[25] VOLATILE CHAR cBADGE[20] VOLATILE INTEGER nVALID_ENTRY VOLATILE INTEGER nDONE VOLATILE CHAR cHOST_NAME[25] VOLATILE CHAR cSTART_DATE[25] VOLATILE CHAR cSTART_HOUR[4] VOLATILE CHAR cSTART_MINUTE[4] VOLATILE CHAR cEND_HOUR[4] VOLATILE CHAR cEND_MINUTE[4] VOLATILE CHAR cSUBJECT[50] VOLATILE INTEGER nMINUTE VOLATILE INTEGER nHOUR VOLATILE INTEGER nMINUTE2 VOLATILE INTEGER nHOUR2 VOLATILE INTEGER nTIME NON_VOLATILE sINTEGER nCURRENT_HOUR NON_VOLATILE sINTEGER nCURRENT_MIN NON_VOLATILE sINTEGER nCURRENT_MEETING VOLATILE LONG nTIMER[] = {500} VOLATILE LONG nTIMER2[] = {5000} VOLATILE LONG nTIMER3[] = {10000} VOLATILE INTEGER nCLOSED NON_VOLATILE DEVCHAN dcMTGs[] = { {dvTP_Locked, 1}, {dvTP_Locked, 2}, {dvTP_Locked, 3}, {dvTP_Locked, 4}, {dvTP_Locked, 5}, {dvTP_Locked, 6}, {dvTP_Locked, 7}, {dvTP_Locked, 8}, {dvTP_Locked, 9}, {dvTP_Locked, 10}, {dvTP_Locked, 11}, {dvTP_Locked, 12}, {dvTP_Locked, 13}, {dvTP_Locked, 14}, {dvTP_Locked, 15}, {dvTP_Locked, 16}, {dvTP_Locked, 17}, {dvTP_Locked, 18}, {dvTP_Locked, 19}, {dvTP_Locked, 20}, {dvTP_Locked, 21}, {dvTP_Locked, 22}, {dvTP_Locked, 23}, {dvTP_Locked, 24}, {dvTP_Locked, 25}, {dvTP_Locked, 26}, {dvTP_Locked, 27}, {dvTP_Locked, 28}, {dvTP_Locked, 29}, {dvTP_Locked, 30}, {dvTP_Locked, 31}, {dvTP_Locked, 32}, {dvTP_Locked, 33}, {dvTP_Locked, 34}, {dvTP_Locked, 35}, {dvTP_Locked, 36} } (***********************************************************) (* LATCHING DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_LATCHING (***********************************************************) (* MUTUALLY EXCLUSIVE DEFINITIONS GO BELOW *) (***********************************************************) DEFINE_MUTUALLY_EXCLUSIVE (***********************************************************) (* SUBROUTINE/FUNCTION DEFINITIONS GO BELOW *) (***********************************************************) (* EXAMPLE: DEFINE_FUNCTION <RETURN_TYPE> <NAME> (<PARAMETERS>) *) (* EXAMPLE: DEFINE_CALL '<NAME>' (<PARAMETERS>) *) DEFINE_FUNCTION INTEGER fnCONVERT_REQUEST (INTEGER nSTART_HOUR, INTEGER nSTART_MINUTE, INTEGER nEND_HOUR, INTEGER nEND_MINUTE) { STACK_VAR INTEGER nDURATION STACK_VAR i STACK_VAR x IF(nSTART_HOUR == 1) { nSTART_HOUR = 13 } ELSE IF(nSTART_HOUR == 2) { nSTART_HOUR = 14 } ELSE IF(nSTART_HOUR == 3) { nSTART_HOUR = 15 } ELSE IF(nSTART_HOUR == 4) { nSTART_HOUR = 16 } IF(nEND_HOUR == 1) { nEND_HOUR = 13 } ELSE IF(nEND_HOUR == 2) { nEND_HOUR = 14 } ELSE IF(nEND_HOUR == 3) { nEND_HOUR = 15 } ELSE IF(nEND_HOUR == 4) { nEND_HOUR = 16 } ELSE IF(nEND_HOUR == 5) { nEND_HOUR = 17 } i = ((nEND_HOUR - nSTART_HOUR)*60) x = nEND_MINUTE - nSTART_MINUTE nDURATION = i + x RETURN nDURATION } DEFINE_FUNCTION INTEGER fnPROCESS_TIME (INTEGER nHOUR, INTEGER nMINUTE) { STACK_VAR INTEGER t IF(nHOUR > 12) { nHOUR = nHOUR - 12 } IF(nHOUR == 8 && nMINUTE < 15) { t = 1 } ELSE IF(nHOUR == 8 && nMINUTE >= 15 && nMINUTE < 30) { t = 2 } ELSE IF(nHOUR == 8 && nMINUTE >= 30 && nMINUTE < 45) { t = 3 } ELSE IF(nHOUR == 8 && nMINUTE >= 45) { t = 4 } ELSE IF(nHOUR == 9 && nMINUTE < 15) { t = 5 } ELSE IF(nHOUR == 9 && nMINUTE >= 15 && nMINUTE < 30) { t = 6 } ELSE IF(nHOUR == 9 && nMINUTE >= 30 && nMINUTE < 45) { t = 7 } ELSE IF(nHOUR == 9 && nMINUTE >= 45) { t = 8 } ELSE IF(nHOUR == 10 && nMINUTE < 15) { t = 9 } ELSE IF(nHOUR == 10 && nMINUTE >= 15 && nMINUTE < 30) { t = 10 } ELSE IF(nHOUR == 10 && nMINUTE >= 30 && nMINUTE < 45) { t = 11 } ELSE IF(nHOUR == 10 && nMINUTE >= 45) { t = 12 } ELSE IF(nHOUR == 11 && nMINUTE < 15) { t = 13 } ELSE IF(nHOUR == 11 && nMINUTE >= 15 && nMINUTE < 30) { t = 14 } ELSE IF(nHOUR == 11 && nMINUTE >= 30 && nMINUTE < 45) { t = 15 } ELSE IF(nHOUR == 11 && nMINUTE >= 45) { t = 16 } ELSE IF(nHOUR == 12 && nMINUTE < 15) { t = 17 } ELSE IF(nHOUR == 12 && nMINUTE >= 15 && nMINUTE < 30) { t = 18 } ELSE IF(nHOUR == 12 && nMINUTE >= 30 && nMINUTE < 45) { t = 19 } ELSE IF(nHOUR == 12 && nMINUTE >= 45) { t = 20 } ELSE IF(nHOUR == 1 && nMINUTE < 15) { t = 21 } ELSE IF(nHOUR == 1 && nMINUTE >= 15 && nMINUTE < 30) { t = 22 } ELSE IF(nHOUR == 1 && nMINUTE >= 30 && nMINUTE < 45) { t = 23 } ELSE IF(nHOUR == 1 && nMINUTE >= 45) { t = 24 } ELSE IF(nHOUR == 2 && nMINUTE < 15) { t = 25 } ELSE IF(nHOUR == 2 && nMINUTE >= 15 && nMINUTE < 30) { t = 26 } ELSE IF(nHOUR == 2 && nMINUTE >= 30 && nMINUTE < 45) { t = 27 } ELSE IF(nHOUR == 2 && nMINUTE >= 45) { t = 28 } ELSE IF(nHOUR == 3 && nMINUTE < 15) { t = 29 } ELSE IF(nHOUR == 3 && nMINUTE >= 15 && nMINUTE < 30) { t = 30 } ELSE IF(nHOUR == 3 && nMINUTE >= 30 && nMINUTE < 45) { t = 31 } ELSE IF(nHOUR == 3 && nMINUTE >= 45) { t = 32 } ELSE IF(nHOUR == 4 && nMINUTE < 15) { t = 33 } ELSE IF(nHOUR == 4 && nMINUTE >= 15 && nMINUTE < 30) { t = 34 } ELSE IF(nHOUR == 4 && nMINUTE >= 30 && nMINUTE < 45) { t = 35 } ELSE IF(nHOUR == 4 && nMINUTE >= 45) { t = 36 } RETURN t } DEFINE_FUNCTION sINTEGER fnFILL_CALENDAR (INTEGER nCURRENT_HOUR, INTEGER nCURRENT_MIN) { STACK_VAR INTEGER x STACK_VAR INTEGER nINDEX FOR(x=1; x<=MAX_LENGTH_ARRAY(uMTG); x++) { IF(LENGTH_STRING(uMTG[x].cSUBJECT) > 0) { IF(uMTG[x].cSUBJECT == uMTG[x].cSUBJECT) { ON[dvTP_Locked, x] } } ELSE { OFF[dvTP_Locked, x] } } IF(nCURRENT_HOUR > 12) { nCURRENT_HOUR = nCURRENT_HOUR - 12 } nINDEX = fnPROCESS_TIME(nCURRENT_HOUR, nCURRENT_MIN) IF(LENGTH_STRING(uMTG[nINDEX].cSUBJECT) > 0) { SEND_COMMAND dvTP, "'^TXT-1,0,',uMTG[nINDEX].cSUBJECT" RETURN TRUE } ELSE { SEND_COMMAND dvTP, "'^TXT-1,0,Vacant'" RETURN FALSE } } DEFINE_FUNCTION INTEGER fnPROCESS_REQUEST (INTEGER nINDEX, INTEGER nNUM_MTGs) { STACK_VAR INTEGER i fnREAD_FILE_MTG('New_Mtg.csv') IF(LENGTH_STRING(uMTG[nINDEX].cSUBJECT) < 1) { FOR(i=1; i<=nNUM_MTGs; i++) { IF(LENGTH_STRING(uMTG[nINDEX].cSUBJECT) < 1) { RETURN TRUE } ELSE IF(LENGTH_STRING(uMTG[nINDEX].cSUBJECT) > 1) { RETURN FALSE BREAK; } nINDEX++ } } } DEFINE_FUNCTION fnRead_BadgeID (CHAR cFILENAME[]) { LOCAL_VAR SLONG slFILE_VAL slFILE_VAL = FILE_OPEN(cFILENAME,FILE_READ_ONLY) IF(slFILE_VAL < 0) { SELECT { ACTIVE(slFILE_VAL == -2): SEND_STRING 0, "'Invalid Path'" ACTIVE(slFILE_VAL == -3): SEND_STRING 0, "'Invalid Value'" ACTIVE(slFILE_VAL == -5): SEND_STRING 0, "'I/O Error'" ACTIVE(slFILE_VAL == -14):SEND_STRING 0, "'Max Files Open'" ACTIVE(slFILE_VAL == -15):SEND_STRING 0, "'Invalid File Format'" } } ELSE IF(slFILE_VAL > 0) { LOCAL_VAR SLONG slVAL LOCAL_VAR INTEGER i LOCAL_VAR CHAR cBUFF[2048] FOR(i=1; i<=MAX_LENGTH_ARRAY(uUSERS); i++) { slVAL = FILE_READ_LINE(slFILE_VAL,cBUFF,MAX_LENGTH_ARRAY(cBUFF)) uUSERS[i].cID = REMOVE_STRING(cBUFF,',',1) SET_LENGTH_STRING(uUSERS[i].cID,LENGTH_STRING(uUSERS[i].cID)-1) uUSERS[i].cFIRST_NAME = REMOVE_STRING(cBUFF,',',1) SET_LENGTH_STRING(uUSERS[i].cFIRST_NAME,LENGTH_STRING(uUSERS[i].cFIRST_NAME)-1) uUSERS[i].cLAST_NAME = REMOVE_STRING(cBUFF,',',1) SET_LENGTH_STRING(uUSERS[i].cLAST_NAME,LENGTH_STRING(uUSERS[i].cLAST_NAME)-1) uUSERS[i].cEMAIL = cBUFF } FILE_CLOSE(slFILE_VAL) } } DEFINE_FUNCTION fnREAD_FILE_MTG (CHAR cFILENAME[]) { LOCAL_VAR SLONG slFILE_VAL slFILE_VAL = FILE_OPEN(cFILENAME,FILE_READ_ONLY) IF(slFILE_VAL < 0) { SELECT { ACTIVE(slFILE_VAL == -2): SEND_STRING 0, "'Invalid Path'" ACTIVE(slFILE_VAL == -3): SEND_STRING 0, "'Invalid Value'" ACTIVE(slFILE_VAL == -5): SEND_STRING 0, "'I/O Error'" ACTIVE(slFILE_VAL == -14):SEND_STRING 0, "'Max Files Open'" ACTIVE(slFILE_VAL == -15):SEND_STRING 0, "'Invalid File Format'" } } ELSE IF(slFILE_VAL > 0) { LOCAL_VAR SLONG slVAL LOCAL_VAR INTEGER i STACK_VAR INTEGER x LOCAL_VAR CHAR cBUFF[2048] FOR(i=1; i<=MAX_LENGTH_ARRAY(uMTG); i++) { slVAL = FILE_READ_LINE(slFILE_VAL,cBUFF,MAX_LENGTH_ARRAY(cBUFF)) uMTG[i].cHOST_NAME = REMOVE_STRING(cBUFF,',',1) SET_LENGTH_STRING(uMTG[i].cHOST_NAME,LENGTH_STRING(uMTG[i].cHOST_NAME)-1) uMTG[i].cSTART_DATE = REMOVE_STRING(cBUFF,',',1) SET_LENGTH_STRING(uMTG[i].cSTART_DATE,LENGTH_STRING(uMTG[i].cSTART_DATE)-1) uMTG[i].cSTART_HOUR = REMOVE_STRING(cBUFF,',',1) SET_LENGTH_STRING(uMTG[i].cSTART_HOUR,LENGTH_STRING(uMTG[i].cSTART_HOUR)-1) uMTG[i].cSTART_MINUTE = REMOVE_STRING(cBUFF,',',1) SET_LENGTH_STRING(uMTG[i].cSTART_MINUTE,LENGTH_STRING(uMTG[i].cSTART_MINUTE)-1) uMTG[i].cEND_HOUR = REMOVE_STRING(cBUFF,',',1) SET_LENGTH_STRING(uMTG[i].cEND_HOUR,LENGTH_STRING(uMTG[i].cEND_HOUR)-1) uMTG[i].cEND_MINUTE = REMOVE_STRING(cBUFF,',',1) SET_LENGTH_STRING(uMTG[i].cEND_MINUTE,LENGTH_STRING(uMTG[i].cEND_MINUTE)-1) uMTG[i].cSUBJECT = cBUFF } FILE_CLOSE(slFILE_VAL) } } DEFINE_FUNCTION fnWRITE_FILE_MTG(CHAR cFILENAME[]) { LOCAL_VAR CHAR cBUFF[2048] LOCAL_VAR SLONG slFILE_VAR LOCAL_VAR INTEGER i LOCAL_VAR SLONG slRESULT slFILE_VAR = FILE_OPEN(cFILENAME,FILE_RW_NEW) IF(slFILE_VAR > 0) { FOR(i=1; i<=MAX_LENGTH_ARRAY(uMTG); i++) { cBUFF = "uMTG[i].cHOST_NAME,',',uMTG[i].cSTART_DATE,',',uMTG[i].cSTART_HOUR,',',uMTG[i].cSTART_MINUTE,',',uMTG[i].cEND_HOUR,',',uMTG[i].cEND_MINUTE,',',uMTG[i].cSUBJECT" slRESULT = FILE_WRITE_LINE(slFILE_VAR,cBUFF,LENGTH_STRING(cBUFF)) } FILE_CLOSE(slFILE_VAR) SEND_STRING 0,"'GOOD FILE CLOSED ',ITOA(FILE_CLOSE(slFILE_VAR))" } ELSE { SEND_STRING 0,"'BAD FILE OPEN ',ITOA(FILE_CLOSE(slFILE_VAR))" } } (***********************************************************) (* STARTUP CODE GOES BELOW *) (***********************************************************) DEFINE_START fnREAD_FILE_MTG('New_Mtg.csv') TIMELINE_CREATE(TL_FEEDBACK, nTIMER, 1, TIMELINE_ABSOLUTE, TIMELINE_REPEAT) //Half Second TIMELINE_CREATE(TL_FEEDBACK2, nTIMER2, 1, TIMELINE_ABSOLUTE, TIMELINE_REPEAT) // 5 Seconds TIMELINE_CREATE(TL_FEEDBACK3, nTIMER3, 1, TIMELINE_ABSOLUTE, TIMELINE_REPEAT) //60 Seconds (***********************************************************) (* THE EVENTS GO BELOW *) (***********************************************************) DEFINE_EVENT DATA_EVENT[dvMaster] //Master Data Event { ONLINE: { SEND_COMMAND dvTP, "'ADBEEP'" //When online, BEEP! } STRING: { IF(FIND_STRING(DATA.TEXT, "'GOOD FILE CLOSED'", 1)) { PULSE[nCLOSED] } } } DATA_EVENT[dvTP] { STRING: { STACK_VAR INTEGER x SEND_STRING 0, "'FROM TP: ', DATA.TEXT" SELECT { ACTIVE(FIND_STRING(DATA.TEXT, 'Button 16-', 1)): { REMOVE_STRING(DATA.TEXT, 'Button 16-', 1) cBADGE = DATA.TEXT IF(LENGTH_STRING(cBADGE == 11)) { fnRead_BadgeID('Badge_IDs.csv') FOR(x=1; x<=MAX_LENGTH_ARRAY(uUSERS); x++) { IF(cBADGE == uUSERS[x].cID) { SEND_COMMAND dvTP, "'@PPN-New Mtg'" SEND_COMMAND dvTP, "'@PPK-Authorization'" SEND_COMMAND dvTP, "'@PPK-Invalid Entry'" SEND_COMMAND dvTP_Mtg, "'^TXT-1,0,',uUSERS[x].cFIRST_NAME,',',uUSERS[x].cLAST_NAME" ON[nVALID_ENTRY] cHOST_NAME = "uUSERS[x].cFIRST_NAME,' ',uUSERS[x].cLAST_NAME" SEND_COMMAND dvTP_Mtg, "'^TXT-2,0,',DATE" BREAK; } ELSE { SEND_COMMAND dvTP, "'@PPN-Invalid Entry'" SEND_COMMAND dvTP, "'@PPK-Authorization'" OFF[nVALID_ENTRY] WAIT 40 { SEND_COMMAND dvTP, "'@PPK-Invalid Entry'" SEND_COMMAND dvTP, "'PAGE-Locked'" } } } } } ACTIVE(FIND_STRING(DATA.TEXT, '@PPF-Authorization;Locked', 1)): { SET_LENGTH_STRING(cHOST_NAME, 0) SET_LENGTH_STRING(cSTART_DATE, 0) SET_LENGTH_STRING(cSTART_HOUR, 0) SET_LENGTH_STRING(cSTART_MINUTE, 0) SET_LENGTH_STRING(cEND_HOUR, 0) SET_LENGTH_STRING(cEND_MINUTE, 0) SET_LENGTH_STRING(cSUBJECT, 0) SEND_COMMAND dvTP_Mtg, "'^TXT-3,0,'" SEND_COMMAND dvTP_Mtg, "'^TXT-4,0,'" SEND_COMMAND dvTP_Mtg, "'^TXT-5,0,'" SEND_COMMAND dvTP_Mtg, "'^TXT-6,0,'" SEND_COMMAND dvTP_Mtg, "'^TXT-11,0,'" SEND_COMMAND dvTP_Mtg, "'^TXT-12,0,'" SEND_COMMAND dvTP_Mtg, "'^TXT-13,0,'" } ACTIVE(FIND_STRING(DATA.TEXT,'KEYB-',1)): { REMOVE_STRING(DATA.TEXT,'KEYB-',1) cDATA = DATA.TEXT } ACTIVE(FIND_STRING(DATA.TEXT,'KEYP-',1)): { REMOVE_STRING(DATA.TEXT,'KEYP-',1) IF(nTIME == 1) { nHOUR = ATOI(DATA.TEXT) } ELSE IF(nTIME == 2) { nMINUTE = ATOI(DATA.TEXT) } ELSE IF(nTIME == 3) { nHOUR2 = ATOI(DATA.TEXT) } ELSE IF(nTIME == 4) { nMINUTE2 = ATOI(DATA.TEXT) } } } PULSE[nDONE] } } BUTTON_EVENT[dvTP_Mtg, 3] { PUSH: { TO[BUTTON.INPUT] nTIME = 1; } RELEASE: { WAIT_UNTIL(nDONE) { cSTART_HOUR = ITOA(nHOUR) SEND_COMMAND dvTP_Mtg, "'^TXT-3,0,',cSTART_HOUR" IF(nHOUR >= 8 && nHOUR < 12) { SEND_COMMAND dvTP_Mtg, "'^TXT-5,0,AM'" } ELSE { SEND_COMMAND dvTP_Mtg, "'^TXT-5,0,PM'" } } } } BUTTON_EVENT[dvTP_Mtg, 4] { PUSH: { nTIME = 2; } RELEASE: { WAIT_UNTIL(nDONE) { cSTART_MINUTE = ITOA(nMINUTE) IF(nMINUTE == 0) { cSTART_MINUTE = "'00'" } SEND_COMMAND dvTP_Mtg, "'^TXT-4,0,',cSTART_MINUTE" } } } BUTTON_EVENT[dvTP_Mtg, 11] { PUSH: { nTIME = 3; } RELEASE: { WAIT_UNTIL(nDONE) { cEND_HOUR = ITOA(nHOUR2) SEND_COMMAND dvTP_Mtg, "'^TXT-11,0,',cEND_HOUR" IF(nHOUR2 >= 8 && nHOUR2 < 12) { SEND_COMMAND dvTP_Mtg, "'^TXT-13,0,AM'" } ELSE { SEND_COMMAND dvTP_Mtg, "'^TXT-13,0,PM'" } } } } BUTTON_EVENT[dvTP_Mtg, 12] { PUSH: { nTIME = 4; } RELEASE: { WAIT_UNTIL(nDONE) { cEND_MINUTE = ITOA(nMINUTE2) IF(nMINUTE2 == 0) { cEND_MINUTE = "'00'" } SEND_COMMAND dvTP_Mtg, "'^TXT-12,0,',cEND_MINUTE" } } } BUTTON_EVENT[dvTP_Mtg, 6] { PUSH: { } RELEASE: { WAIT_UNTIL(nDONE) { cSUBJECT = cDATA SEND_COMMAND dvTP_Mtg, "'^TXT-6,0,',cSUBJECT" } } } BUTTON_EVENT[dvTP_Mtg, 10] //reserve a new meeting { PUSH: { LOCAL_VAR INTEGER x LOCAL_VAR INTEGER INDEX LOCAL_VAR INTEGER nDURATION LOCAL_VAR INTEGER nNUM_MTGS LOCAL_VAR INTEGER ACCESS INDEX = fnPROCESS_TIME(nHOUR, nMINUTE) nDURATION = fnCONVERT_REQUEST(nHOUR, nMINUTE, nHOUR2, nMINUTE2) nNUM_MTGS = (nDURATION/15) ACCESS = fnPROCESS_REQUEST(INDEX, nNUM_MTGS) IF(LENGTH_STRING(cSUBJECT) > 0) { OFF[dvTP_Mtg, 16] IF(ACCESS == 1) { FOR(x=1; x<=nNUM_MTGS; x++) { uMTG[INDEX].cHOST_NAME = cHOST_NAME uMTG[INDEX].cSTART_DATE = DATE uMTG[INDEX].cSTART_HOUR = cSTART_HOUR uMTG[INDEX].cSTART_MINUTE = cSTART_MINUTE uMTG[INDEX].cEND_HOUR = cEND_HOUR uMTG[INDEX].cEND_MINUTE = cEND_MINUTE uMTG[INDEX].cSUBJECT = cSUBJECT fnWRITE_FILE_MTG('New_Mtg.csv') INDEX++ IF(x == nNUM_MTGs) { BREAK; } } SEND_COMMAND dvTP, "'@PPX-New Mtg'" } ELSE IF(ACCESS == 0) { SEND_COMMAND dvTP, "'@PPN-Error'" } } ELSE { ON[dvTP_Mtg, 16] } } } BUTTON_EVENT[dvTP, 4] //Cancel the current meeting { PUSH: { LOCAL_VAR INTEGER i LOCAL_VAR INTEGER nDURATION2 LOCAL_VAR INTEGER nNUM_MTGs2 LOCAL_VAR INTEGER nLINE nLINE = fnPROCESS_TIME(nCURRENT_HOUR, nCURRENT_MIN) nDURATION2 = fnCONVERT_REQUEST(ATOI(uMTG[nLINE].cSTART_HOUR), ATOI(uMTG[nLINE].cSTART_MINUTE), ATOI(uMTG[nLINE].cEND_HOUR), ATOI(uMTG[nLINE].cEND_MINUTE)) nNUM_MTGs2 = (nDURATION2/15) FOR(i=1; i<=nNUM_MTGS2; i++) { SET_LENGTH_STRING(uMTG[nLINE].cHOST_NAME, 0) SET_LENGTH_STRING(uMTG[nLINE].cSTART_DATE, 0) SET_LENGTH_STRING(uMTG[nLINE].cSTART_HOUR, 0) SET_LENGTH_STRING(uMTG[nLINE].cSTART_MINUTE, 0) SET_LENGTH_STRING(uMTG[nLINE].cEND_HOUR, 0) SET_LENGTH_STRING(uMTG[nLINE].cEND_MINUTE, 0) SET_LENGTH_STRING(uMTG[nLINE].cSUBJECT, 0) fnWRITE_FILE_MTG('New_Mtg.csv') nLINE++ IF(i == nNUM_MTGs2) { BREAK; } } } } BUTTON_EVENT[dcMTGs] { PUSH: { STACK_VAR INTEGER BIC BIC = BUTTON.INPUT.CHANNEL ON[dvTP, 6] ON[dvTP, 7] IF(LENGTH_STRING(uMTG[BIC].cSUBJECT) > 0) { SEND_COMMAND dvTP, "'^TXT-2,0,',uMTG[BIC].cSUBJECT,' ',uMTG[BIC].cSTART_HOUR,':',uMTG[BIC].cSTART_MINUTE,' - ',uMTG[BIC].cEND_HOUR,':',uMTG[BIC].cEND_MINUTE" } ELSE { SEND_COMMAND dvTP, "'^TXT-2,0,Meeting room available'" } WAIT 50 { OFF[dvTP, 6] OFF[dvTP, 7] } } } BUTTON_EVENT[dvTP, 3] { PUSH: { STACK_VAR INTEGER y y = fnPROCESS_TIME(nCURRENT_HOUR, nCURRENT_MIN) IF(LENGTH_STRING(uMTG[y].cSUBJECT) > 0) { SEND_COMMAND dvTP, "'^TXT-3,0,',uMTG[y].cSUBJECT" } ELSE { SEND_COMMAND dvTP, "'^TXT-3,0,There is no meeting to cancel...'" } } } TIMELINE_EVENT[TL_FEEDBACK] { nCURRENT_HOUR = TIME_TO_HOUR(TIME) nCURRENT_MIN = TIME_TO_MINUTE(TIME) } TIMELINE_EVENT[TL_FEEDBACK2] { nCURRENT_MEETING = fnFILL_CALENDAR(nCURRENT_HOUR, nCURRENT_MIN) } TIMELINE_EVENT[TL_FEEDBACK3] { fnREAD_FILE_MTG('New_Mtg.csv') } (***********************************************************) (* THE ACTUAL PROGRAM GOES BELOW *) (***********************************************************) DEFINE_PROGRAM [dvTP, 1] = (nCURRENT_MEETING == 1) (***********************************************************) (* END OF PROGRAM *) (* DO NOT PUT ANY CODE BELOW THIS COMMENT *) (***********************************************************)
0
Comments
When you say "extends cSubject to 16" do you mean it truncates the 50 characters to 16?
Can you post the contents of the file?
it truncates to 16 yes, the file doesnt show any characters, although they may be blank spaces. Thoughts?
slRESULT = FILE_WRITE_LINE(slFILE_VAR,cBUFF,LENGTH_STRING(cBUFF))
I'd change that to "LENGTH_ARRAY" and see if you get different results.
I remember getting inconsistent results with the "LENGTH_STRING" command.
Since it is an Axcess command, best to avoid it anyhow.
Also, you may want to SEND_STRING 0 the "slRESULT" var to see how many characters are actually getting written to the line.
Whoa... I've never seen that command before... or the VARIABLE_TO_XML command.
Thanks for teaching me something new. What does it convert the structure to? A CSV line?
Interesting...
Really? Doesn't that defeat the purpose for using XML?
Not really, its more to do when you nest a structure, you know, put one sturcture within another.