Page 1 of 1
How to save CRLF in editorgadget to database and back?
Posted: Thu Jun 19, 2014 1:57 pm
by Fangbeast
I can't remember how I did this years ago but when I type some text into an editorgadget and save the text to a database, bringing it back comes back truncated and messed up.
How do you handle this?
I tried some RTF routines thinking it would solve the problem but it didn't
Re: How to save CRLF in editorgadget to database and back?
Posted: Thu Jun 19, 2014 2:10 pm
by walker
Hi,
i'd solved this by parsing the text and replacing the CRLF by another character that never will occur and has no meaning to the database. Chr(7) is such a char
Or replace the CRLF by the HTML equivalent "<br>"
If you read the database, reverse your search

Re: How to save CRLF in editorgadget to database and back?
Posted: Thu Jun 19, 2014 2:14 pm
by Fangbeast
walker wrote:Hi,
i'd solved this by parsing the text and replacing the CRLF by another character that never will occur and has no meaning to the database. Chr(7) is such a char
Or replace the CRLF by the HTML equivalent "<br>"
If you read the database, reverse your search

Thanks for that. I still have trouble remembering things I lost years ago
Re: How to save CRLF in editorgadget to database and back?
Posted: Thu Jun 19, 2014 6:57 pm
by falsam
Try this code: When the code is run, copy this code in the editor, save and load.
Code: Select all
Enumeration database
#database
EndEnumeration
Enumeration window
#mainform
EndEnumeration
Enumeration gadget
#editor
#save
#load
EndEnumeration
Procedure.s DoubleSpec(String.s)
Protected Buffer.s
Buffer = ReplaceString(String, "'", "''")
ProcedureReturn Buffer
EndProcedure
Procedure databasesave()
Protected buffer.S = DoubleSpec(GetGadgetText(#editor))
DatabaseUpdate(#database, "insert into MyTable (editor) values('" + buffer+ "')")
Debug DatabaseError()
SetGadgetText(#editor, "")
EndProcedure
Procedure databaseload()
DatabaseQuery(#database, "SELECT editor FROM MyTable")
NextDatabaseRow(#database)
SetGadgetText(#editor, GetDatabaseString(#database, 0))
EndProcedure
UseSQLiteDatabase()
OpenDatabase(#database, ":memory:", "", "")
DatabaseUpdate(#database, "CREATE TABLE MyTable (editor TEXT);")
OpenWindow(#mainform, 0, 0, 800, 600, "Save Editor to Database")
EditorGadget(#editor, 5, 5, 700, 595)
ButtonGadget(#save, 710, 5, 80, 22, "Save")
ButtonGadget(#load, 710, 30, 80, 22, "Load")
SetActiveGadget(#Editor)
BindGadgetEvent(#save, @databasesave())
BindGadgetEvent(#load, @databaseload())
Repeat : Until WaitWindowEvent(10) = #PB_Event_CloseWindow
Re: How to save CRLF in editorgadget to database and back?
Posted: Thu Jun 19, 2014 9:42 pm
by Fangbeast
I have no trouble with database in general falsam, just forgot how to deal with pesky crlf's. I'm getting OLDer!!

:)
Re: How to save CRLF in editorgadget to database and back?
Posted: Sun Aug 30, 2015 10:27 am
by Olliv
Fangbeast
replacing effective new line characters with this RTF string:
?
Re: How to save CRLF in editorgadget to database and back?
Posted: Mon May 02, 2022 10:27 pm
by Olli
Hey fangbeast ! It was a question !
/par means paragraph so it does a carriage return...
I apologize to have been late (2 months) to answer : in Juny, 2014 I had an car accident...
I am searching where I published a highlight test in a EditorGadget...
Re: How to save CRLF in editorgadget to database and back?
Posted: Tue May 03, 2022 5:33 am
by Fangbeast
2 months?? Don't you mean 7 years?????
Stop having accidents, come over here and help me move:):)