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
How to save CRLF in editorgadget to database and back?
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
How to save CRLF in editorgadget to database and back?
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Re: How to save CRLF in editorgadget to database and back?
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
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

- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Re: How to save CRLF in editorgadget to database and back?
Thanks for that. I still have trouble remembering things I lost years agowalker 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
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Re: How to save CRLF in editorgadget to database and back?
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
➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti
Sorry for my bad english and the Dunning–Kruger effect
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Re: How to save CRLF in editorgadget to database and back?
I have no trouble with database in general falsam, just forgot how to deal with pesky crlf's. I'm getting OLDer!!
:)

Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Re: How to save CRLF in editorgadget to database and back?
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...

/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...
- Fangbeast
- PureBasic Protozoa
- Posts: 4789
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Re: How to save CRLF in editorgadget to database and back?
2 months?? Don't you mean 7 years?????
Stop having accidents, come over here and help me move:):)
Stop having accidents, come over here and help me move:):)
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet