Remove Carriage Returns
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Remove Carriage Returns
I have a description field that is called from a MySQL database. It has carriage returns and/or line feeds that cause parts of the text to go to Description field in a new row it creates, then into the next row, and the next row, until all the returns in the field are used. The problem is how to keep the whole contents in one field so that the returns don't cause it to go to the next Description field.
Looked far and wide but found nothing that worked.
Looked far and wide but found nothing that worked.
Last edited by bbhank on Thu Mar 31, 2016 2:39 pm, edited 1 time in total.
-
- Livecode Opensource Backer
- Posts: 1336
- Joined: Sun Jul 12, 2009 10:53 am
- Location: Bordeaux, France
Re: Remove Carriage Returns
try something like...
Code: Select all
replace return with empty in fld "xyz"
Re: Remove Carriage Returns
This does go in the Row Behavior, right?
If so, it doesn't work.
Also tried in field script and changing fld to field in each.
Doesn't work there either.
Suggestions?
If so, it doesn't work.
Also tried in field script and changing fld to field in each.
Doesn't work there either.
Suggestions?
-
- Livecode Opensource Backer
- Posts: 1336
- Joined: Sun Jul 12, 2009 10:53 am
- Location: Bordeaux, France
Re: Remove Carriage Returns
Oh, so you are using a datagrid are you !?... You didn't make that clear... look up 'replace' in the dictionary'
Re: Remove Carriage Returns
Found this: replaceText(stringToChange, matchExpression, replacementString) from Dictionary.
then
replaceText("Description","cr"," ") looks like it should work.
Does not work. Not enough information. The field is Description.
I want to either remove or change carriage returns so that they do not cause the text to flow into the next Description field.
then
replaceText("Description","cr"," ") looks like it should work.
Does not work. Not enough information. The field is Description.
I want to either remove or change carriage returns so that they do not cause the text to flow into the next Description field.
-
- VIP Livecode Opensource Backer
- Posts: 7266
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Remove Carriage Returns
ReplaceText is used for regular expressions, which is probably overkill for what you're doing. "Replace" is all you need.
One reason your replaceText function didn't work is because you quoted "cr", which is a constant and should not have quotes. By using quotation marks you're making it a literal string, which will only match the exact two characters "cr". Another reason is that replaceText is a function, so if you called it like a command it will fail (it isn't clear if you did that.) Finally, "description" isn't a full object reference, so replaceText will use it as the literal string to search.
Bernd's original suggestions should work as written.
One reason your replaceText function didn't work is because you quoted "cr", which is a constant and should not have quotes. By using quotation marks you're making it a literal string, which will only match the exact two characters "cr". Another reason is that replaceText is a function, so if you called it like a command it will fail (it isn't clear if you did that.) Finally, "description" isn't a full object reference, so replaceText will use it as the literal string to search.
Bernd's original suggestions should work as written.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Remove Carriage Returns
I think the intrinsic problem is that the records retrieved from the query are cr delimited rows, but each row contains a column with multiple return characters.
Try fetching the data with a query that changes the default record separator, to something you can be sure is not in the dB.
Then replace cr with empty in theFetchedData. Next replace "myFunkySeparator" with cr in theFetchedData.
Maybe then you can apply theFetchedData to the datagrid and have it show properly.
Try fetching the data with a query that changes the default record separator, to something you can be sure is not in the dB.
Then replace cr with empty in theFetchedData. Next replace "myFunkySeparator" with cr in theFetchedData.
Maybe then you can apply theFetchedData to the datagrid and have it show properly.
Re: Remove Carriage Returns
Tried these but still no go:
replace cr with " " in field "Description"
replace return with empty in fld "Description"
Used with and without "of me"
replace cr with " " in field "Description"
replace return with empty in fld "Description"
Used with and without "of me"
Re: Remove Carriage Returns
This is all in one field. Checked using MS Word to see which caused the problem and found that both line feeds and returns, here, cause this. Also that the tried the methods above to remove them but that so far none have worked. How could this be achieved with a query if these are in one field only? I've looked for this also.
Re: Remove Carriage Returns
How do you fetch the data from the database?
Please show us your Livecode and SQL commands.
Is your datagrid of type TABLE of FORM?
Please show us your Livecode and SQL commands.
Is your datagrid of type TABLE of FORM?
Re: Remove Carriage Returns
put "SELECT event_state, other_field1, other_field2, other_field3, event_desc FROM wp_my_database WHERE event_state='"& gState &"' ORDER BY event_begin ASC " into tSQL
The state - gState - comes from pull down menu.
DataGrid is form.
The state - gState - comes from pull down menu.
DataGrid is form.
Last edited by bbhank on Thu Mar 31, 2016 6:35 pm, edited 1 time in total.
Re: Remove Carriage Returns
OK, that is the SQL command. What about the LC command you are using the SQL in?bbhank wrote:put "SELECT other_field, other_field1, other_field2, other_field3, event_desc FROM wp_my_database WHERE event_state='"& gState &"' ORDER BY event_begin ASC " into tSQL
Aha?bbhank wrote:The state comes from pull down menu.
Please answer my other question.
Re: Remove Carriage Returns
DataGrid is form.
Re: Remove Carriage Returns
When I took out the linefeeds and carriage returns in Word and pasted that back into the original field in the database, it became "normal" when displayed in LiveCode.
Re: Remove Carriage Returns
Sure it did!
Still waiting for my last question to be answered, so much for "Succinct answers...".
Still waiting for my last question to be answered, so much for "Succinct answers...".