Remove Carriage Returns
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Remove Carriage Returns
Your last question asked was the DataGrid a form? I've answered it twice. It is a form.
Re: Remove Carriage Returns
Of course I meant my last unanswered (sic!) question.
Re: Remove Carriage Returns
OK, that is the SQL command. What about the LC command you are using the SQL in?
The one posted was it. The SQL and LC are all together.
The one posted was it. The SQL and LC are all together.
Re: Remove Carriage Returns
set the text of field "Description" of me to pDataArray["label 11"]
is used to populate the Description field in the Row Behavior. The event_description is the 11th item in the array.
Hope that helps some.
is used to populate the Description field in the Row Behavior. The event_description is the 11th item in the array.
Hope that helps some.
Re: Remove Carriage Returns
No, that was only the SQL part!bbhank wrote:OK, that is the SQL command. What about the LC command you are using the SQL in?
The one posted was it. The SQL and LC are all together.
You are also using something like "revexecute..." or "revdatafromquery..." to finally execute the SQL command, right?
And THAT is the LC part that I mean.
Re: Remove Carriage Returns
Yes. Here: put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData in the query part.
-
- VIP Livecode Opensource Backer
- Posts: 7229
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Remove Carriage Returns
You're doing to us what you say the dictionary does to you.
Klaus (and I) would like to know exactly where you were trying to adjust the text. Was it in the behavior script? Which handler? "FillInData"? (That's where I would have done it.)
Of course, the easiest solution is what you actually did. Updating the database source is faster and easier than manipulating the text as it comes into LC.
Klaus (and I) would like to know exactly where you were trying to adjust the text. Was it in the behavior script? Which handler? "FillInData"? (That's where I would have done it.)
Of course, the easiest solution is what you actually did. Updating the database source is faster and easier than manipulating the text as it comes into LC.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Remove Carriage Returns
Please excuse delay. Had to run out. And thank you all.
I've been trying both in the query, as per stuff I found outside LiveCode, and from the Row Behavior - set the text of field "Description" of me to pDataArray["label 11"].
I only updated the database to see if that was the issue. If I change records in the database I risk the ire of customers who use the main program on the web. Users do things like using spaces and returns to make text look and feel like they want so they can print what they see. That makes this problem worse by adding more carriage returns and line feeds. The main program, a calendar, does not see any of this so they can format their Descriptions any way they see fit. The other is where many of the descriptions are pasted in, especially from Acrobat. You probably know what problems can arise from copying and pasting from that .
I've been trying both in the query, as per stuff I found outside LiveCode, and from the Row Behavior - set the text of field "Description" of me to pDataArray["label 11"].
I only updated the database to see if that was the issue. If I change records in the database I risk the ire of customers who use the main program on the web. Users do things like using spaces and returns to make text look and feel like they want so they can print what they see. That makes this problem worse by adding more carriage returns and line feeds. The main program, a calendar, does not see any of this so they can format their Descriptions any way they see fit. The other is where many of the descriptions are pasted in, especially from Acrobat. You probably know what problems can arise from copying and pasting from that .
-
- VIP Livecode Opensource Backer
- Posts: 7229
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Remove Carriage Returns
Okay, good. Can we see your fillInData handler from the row behavior script? That's where the adjustment should go.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 7229
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Remove Carriage Returns
Oh wait, I've got enough info from your other response:
Code: Select all
put pDataArray["label 11"] into tData
replace cr with empty in tData
set the text of field "Description" of me to tData
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Remove Carriage Returns
Hi,
a few more hints about this:is a potential culprit. It adds additional linefeeds (see Dictionary CR, which is synonym to Return).
When working with data containing such already you'll want to use other delimiters, for instance:
This way you'll get the delimiters not conflicting with your data. Now do:
(see Dictionary CRLF)
You have nice, clear data now. Try:this should give you an array to feed to a DataGrid.
For sure, you could always use:instead of the above paragraph.
Got the idea? Have fun!
PS: I see, Jacque was faster. Anyways, if I wrote this already, I can send it too :)
a few more hints about this:
Code: Select all
Here: put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData
When working with data containing such already you'll want to use other delimiters, for instance:
Code: Select all
Here: put revDataFromQuery(numtochar(1), Numtochar(2), gConnectionID, tSQL) into tData
Code: Select all
replace CRLF with return in tData
You have nice, clear data now. Try:
Code: Select all
split tData by numtochar(1) and Numtochar(2)
For sure, you could always use:
Code: Select all
replace CRLF with empty in tData
replace return with empty in tData
replace numtochar(1) with tab in tData
replace numtochar(2) with return in tData
Got the idea? Have fun!
PS: I see, Jacque was faster. Anyways, if I wrote this already, I can send it too :)
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
Re: Remove Carriage Returns
Here ya go:
Code: Select all
on FillInData pDataArray
set the text of field "City" of me to pDataArray["label 1"]
set the text of field "State" of me to pDataArray["label 2"]
convert pDataArray["label 3"] to long date
set the text of field "Begins" of me to pDataArray["label 3"]
set the text of field "Title" of me to pDataArray["label 4"]
set the text of field "Lane" of me to pDataArray["label 5"]
set the text of field "Street" of me to pDataArray["label 6"]
set the text of field "Link" of me to pDataArray["label 7"]
get wordWrapped(field "Link",35)
-- put wordWrapped(myText,the length of line 1 of me) after me
put wordWrapped(it) into field "Link" of me
set the text of field "Phone" of me to pDataArray["label 8"]
set the text of field "Zipcode" of me to pDataArray["label 9"]
set the text of field "Category" of me to pDataArray["label 10"]
-- set the text of field "Description" of me to pDataArray["label 11"]
end FillInData
Re: Remove Carriage Returns
Yep, that is exactly the problem here!AxWald wrote:is a potential culprit. It adds additional linefeeds (see Dictionary CR, which is synonym to Return).Code: Select all
Here: put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData
When working with data containing such already you'll want to use other delimiters, for instance:This way you'll get the delimiters not conflicting with your data. Now do:Code: Select all
Here: put revDataFromQuery(numtochar(1), Numtochar(2), gConnectionID, tSQL) into tData
(see Dictionary CRLF)Code: Select all
replace CRLF with return in tData
You have nice, clear data now. Try:this should give you an array to feed to a DataGrid..Code: Select all
split tData by numtochar(1) and Numtochar(2)
bbhank, do you understand why this is causing your problem?
It is important to konw and understand how and why something works in any programming environment.
Re: Remove Carriage Returns
I think so. IF I'm understanding you correctly, looks like we're taking the returns out of the whole query results, then splitting that up. It's the Description field only I'm asking about. Taking them out of tData wrecks everything. The problem only happens when the Description field is loaded.
replace CRLF with "---" in field "Description" seems to have no effect. I know they are there because i can take them out with Word and get a "normal" field, in that the data is totally contained in one field and row.
replace CRLF with "---" in field "Description" seems to have no effect. I know they are there because i can take them out with Word and get a "normal" field, in that the data is totally contained in one field and row.
Re: Remove Carriage Returns
Hi bbhank,
Please take alook at the first 2 parameters of this function -> TAB and CR
This way the data returned from the database will be delimited by TAB for
database fields belonging to one database record and all records delimited
by CR (RETURN).
This is great for ONE LINE content like any address database like in this example:
name1 TAB firstname1 TAB telephone1 CR
name2 TAB firstname2 TAB telephone2 CR
...
You get the picture!
But if the content of a database field already contains any CR it will completely
spoil your intention, as you have experienced.
So we need to take another RECORD delimiter for your query, some thong that is surely
NOT part of the text in the database fields.
That is why AxWald use numtochar(1) resp. numtochar(2).
These "characters" cannot be typed with the keyboard and so the contained CRs will not
destroy your layout.
Of course you will need to take this into account when converting your data to an array for
the datagrid.
Hope this is clearer now.
Best
Klaus
Code: Select all
...
put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData
...
This way the data returned from the database will be delimited by TAB for
database fields belonging to one database record and all records delimited
by CR (RETURN).
This is great for ONE LINE content like any address database like in this example:
name1 TAB firstname1 TAB telephone1 CR
name2 TAB firstname2 TAB telephone2 CR
...
You get the picture!
But if the content of a database field already contains any CR it will completely
spoil your intention, as you have experienced.
So we need to take another RECORD delimiter for your query, some thong that is surely
NOT part of the text in the database fields.
That is why AxWald use numtochar(1) resp. numtochar(2).
These "characters" cannot be typed with the keyboard and so the contained CRs will not
destroy your layout.
Of course you will need to take this into account when converting your data to an array for
the datagrid.
Hope this is clearer now.
Best
Klaus