Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Add text to file

Author
Message
Kiaurutis
13
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 30th Sep 2012 21:57
I needed to add text to my file, but there is no simple function for doing this, and can't find any threads about this... How do you ppl edit your databases?

I made some simple function for that, but it adds empty line too... Maybe someone has something better, or know how to fix that?



Join The dark Side! We have cookies
Lucas Tiridath
AGK Developer
16
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 1st Oct 2012 00:39 Edited at: 1st Oct 2012 00:41
Quote: "I needed to add text to my file, but there is no simple function for doing this"

Not in DBP's native commands but there is in the Matrix1 Utils. If you've not got this plugin yet, you really should. It's incredibly handy. You can find it here. Below is your code adapted to use the plugin's datafile commands. As you can see, they are a lot simpler than the current method and avoid your carriage return issue.



By the way, I think you had missed the 'e' off a couple of the file variables in your code here.

Anyhow back to the issue of why your code is having the extra carriage return problem, I've run your code and can confirm the issue. I believe that the write string command writes the string to the file and appends a carriage return to demarcate the different strings in a file. However it looks like the read string command may be reading the carriage return back into the string so when you use write string again, you now have two carriage returns instead of one. I've not been able to verify this as attempting simply to remove the last character of the string before writing it back does what you would expect (removes the 'i' from "Hi") and doesn't resolve the carriage return issue. However I did notice that when your variable is replaced with a string literal, the issue disappears so it is something to do with the variable.

Sorry I couldn't solve that for you (maybe someone else here has an idea of why it is happening?) but in reality, I think you are better off with the Matrix1 solution anyway.

Hope that helps .

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 1st Oct 2012 02:56 Edited at: 1st Oct 2012 02:59
PAID TOOLS
Dark Data enables a database driven system...which can be encrypted as well... a propriety system if you will... [Meaning unless you developed a way to read the data using another language or application it pretty much works in DBP applications only...correct me if I was wrong...]

STYX enables the use of .ini .xml type databases which are portable to other applications...

.ini is usually good for storing application information... [Not necessarily a database files type]

.xml is a good portable database which can be imported into other database systems... if you structure it well enough...

OTHER / FREE TOOLS
I cannot remember what allows the usage of .csv files might be Matrix1Utils which I believe also allows for .xml manipulation so maybe look into that...

Hope this helps...

EDIT

Fixed a bad formatting issue, added further description...

Kiaurutis
13
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 1st Oct 2012 23:22
I got Matrix1 Utils and when I see the list of commands...
Fortunately, Lucas wrote a snippet for my function Thank You!!! It helped

PS that was 2 separate strings:
fil$ for main program use
file$ to use inside function

Join The dark Side! We have cookies
Lucas Tiridath
AGK Developer
16
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 2nd Oct 2012 00:21
Quote: "Thank You!!! It helped"

You're welcome

Quote: "PS that was 2 separate strings:
fil$ for main program use
file$ to use inside function"

Ah ha, but consider lines 2 and 3 and you'll see what I mean


Kiaurutis
13
Years of Service
User Offline
Joined: 19th Jan 2011
Location: Lithuania
Posted: 2nd Oct 2012 08:31
wooops...

Join The dark Side! We have cookies

Login to post a reply

Server time is: 2024-11-21 23:36:07
Your offset time is: 2024-11-21 23:36:07