Retrieving text from mysql to datagrid form
Posted: Sat May 09, 2020 12:23 pm
Hello everyone...god to be here!
I'm a brand new member, but reading this forum for over many years now. Using livecode opened a new world to me: it has brought an easy programming language and a lot to learn about creating cross-platform apps - many pleasures on the way learning. Thanks for that.
I've run into a situation with datagrid form, as follows:
- Using mysql DB
- user enters text into input field: multiline text, using cr, tab, enter backspace etc.
"let say something like this...
multiline using
this is a sample"
- save it to mysql /in the DB is text or varchar/ column names are "KERD" and "SORR"
- on the card that i have the datagrid form, there is the script in opencard to fill the form:
--------------------------------------
put revDataFromQuery(NUMTOCHAR(1),NUMTOCHAR(2), czConnID, tSQL) into tData
------------ trying to clear tData
replace CR with "" in tData
replace CRLF with "" in tData
replace tab with "" in tData
-----------replace tData to normal format tried this also: SPLIT tData BY numtochar(1) AND numtochar(2)
replace NUMTOCHAR(1) with tab in tData
replace NUMTOCHAR(2) with cr in tData
----------finally put it to an array for the Behaivor Script of the Row Template
put 0 into tLineCounter
set itemdel to TAB --- tried everything NUMTOCHAR(1),NUMTOCHAR(2) ----ONLY TAB OR CR ???
repeat for each line tLine in tData
add 1 to tLineCounter
put item 1 of tLine into pDataArray[tLineCounter]["KERD"]
put item 2 of tLine into pDataArray[tLineCounter]["SORR"]
end repeat
Set the dgData of group "DGK" OF CARD "FILL" to pDataArray
---------------------------- end --------------------------
- in the Behaivor Script of the Row Template have the following in FillInData:
set the text of field "KERDES" of me to pDataArray["KERD"]
set the text of field "SORREND" of me to pDataArray["SORR"]
- after all playing around with the lines of tData - before set it to pDataArray -, 1 have never received the originaly entered text into the field i have created in row template. Sometimes all of the lines of the original text went into a new row /probably cr,crlf etc/, another time all of the text which supposed to go to different rows, went into one single row, an such other nightamares occured.
What is i am doing wrong? Am i using the right approach to convert tData, am i doing it on the right place or should it be done in row template script etc. So many things i'm unsure. Please direct me to the right direction...
I'm a brand new member, but reading this forum for over many years now. Using livecode opened a new world to me: it has brought an easy programming language and a lot to learn about creating cross-platform apps - many pleasures on the way learning. Thanks for that.
I've run into a situation with datagrid form, as follows:
- Using mysql DB
- user enters text into input field: multiline text, using cr, tab, enter backspace etc.
"let say something like this...
multiline using
this is a sample"
- save it to mysql /in the DB is text or varchar/ column names are "KERD" and "SORR"
- on the card that i have the datagrid form, there is the script in opencard to fill the form:
--------------------------------------
put revDataFromQuery(NUMTOCHAR(1),NUMTOCHAR(2), czConnID, tSQL) into tData
------------ trying to clear tData
replace CR with "" in tData
replace CRLF with "" in tData
replace tab with "" in tData
-----------replace tData to normal format tried this also: SPLIT tData BY numtochar(1) AND numtochar(2)
replace NUMTOCHAR(1) with tab in tData
replace NUMTOCHAR(2) with cr in tData
----------finally put it to an array for the Behaivor Script of the Row Template
put 0 into tLineCounter
set itemdel to TAB --- tried everything NUMTOCHAR(1),NUMTOCHAR(2) ----ONLY TAB OR CR ???
repeat for each line tLine in tData
add 1 to tLineCounter
put item 1 of tLine into pDataArray[tLineCounter]["KERD"]
put item 2 of tLine into pDataArray[tLineCounter]["SORR"]
end repeat
Set the dgData of group "DGK" OF CARD "FILL" to pDataArray
---------------------------- end --------------------------
- in the Behaivor Script of the Row Template have the following in FillInData:
set the text of field "KERDES" of me to pDataArray["KERD"]
set the text of field "SORREND" of me to pDataArray["SORR"]
- after all playing around with the lines of tData - before set it to pDataArray -, 1 have never received the originaly entered text into the field i have created in row template. Sometimes all of the lines of the original text went into a new row /probably cr,crlf etc/, another time all of the text which supposed to go to different rows, went into one single row, an such other nightamares occured.
What is i am doing wrong? Am i using the right approach to convert tData, am i doing it on the right place or should it be done in row template script etc. So many things i'm unsure. Please direct me to the right direction...