Recent

Author Topic: database without external file  (Read 5070 times)

azaky

  • Newbie
  • Posts: 4
database without external file
« on: January 16, 2012, 02:55:22 pm »
I want to make a database that is editable without the need of any external files. Is there any option to make it?

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: database without external file
« Reply #1 on: January 16, 2012, 03:28:43 pm »
So basically you want to modify the executable while it's running? I don't really know any database or storage method that isn't stored in a separate file somewhere. Even when using Windows registry it is a file in the end, but less visible one.

JanRoza

  • Hero Member
  • *****
  • Posts: 605
    • http://www.silentwings.nl
Re: database without external file
« Reply #2 on: January 16, 2012, 03:48:38 pm »
And using a modifying-itself program file I think antivirus programs will have a field day.
Program files shouldn't be modified, data should be separate from your program (my humble opinion).
How do you plan to upgrade your program when a user already is using the older version for some time without loosing his data?
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
Laz: Lazarus 2.0.10 FPC 3.2.0
       CodeTyphon 7.3 FPC 3.3.1

azaky

  • Newbie
  • Posts: 4
Re: database without external file
« Reply #3 on: January 16, 2012, 03:59:10 pm »
hmm, so it is impossible to do so? Actually I always wonder how, for example, those mini games which (apparently) only have a single executable file, but it can save things such as highscores. I thought lazarus can do the same thing.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3935
  • I like bugs.
Re: database without external file
« Reply #4 on: January 16, 2012, 05:03:27 pm »
hmm, so it is impossible to do so? Actually I always wonder how, for example, those mini games which (apparently) only have a single executable file, but it can save things such as highscores. I thought lazarus can do the same thing.

Those games can make a hidden file to user's home directory or they can use Windows registry. You could do the same.
A program can also store user's profile data to a server through internet connection.

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

fredycc

  • Sr. Member
  • ****
  • Posts: 264
Re: database without external file
« Reply #5 on: January 16, 2012, 05:05:44 pm »
Many times the file is created when you launch the application on any current user's path also has hidden attributes, sometimes if the game is through a login before you download a file with the most recent game items or cookies if they are web applications like JuhaManninen suggest you, if we talk about data sets could be in a single XML file only.

Regards

azaky

  • Newbie
  • Posts: 4
Re: database without external file
« Reply #6 on: January 16, 2012, 05:43:12 pm »
thanks for the replies guys! I am very new in programming with lazarus, so I don't know so much about databases.
btw making files invisible is a good idea, but how to set that file to be invisible?

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: database without external file
« Reply #7 on: January 16, 2012, 06:04:03 pm »
Also remember that you should not store data in the program directory unless really necessary. Doing that essentially makes the program unusable for limited users, and is a bad practice.
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

Leledumbo

  • Hero Member
  • *****
  • Posts: 8286
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: database without external file
« Reply #8 on: January 17, 2012, 05:48:04 am »
Quote
how to set that file to be invisible?
under *nix: start the filename with . (dot)
under windows: change the hidden attribute to true

azaky

  • Newbie
  • Posts: 4
Re: database without external file
« Reply #9 on: January 17, 2012, 12:16:25 pm »
Quote
how to set that file to be invisible?
under *nix: start the filename with . (dot)
under windows: change the hidden attribute to true

Do you mean by setting the file properties? After googling, I found that it can be done with FileSetAttr. But now I have another problem. Each time I want to retrieve data from hidden files, it always returns RunError(5). Should I set the file to be not hidden each time I want to read it?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8286
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: database without external file
« Reply #10 on: January 17, 2012, 04:17:21 pm »
http://www.freepascal.org/docs-html/user/userap4.html
See error code 5.
Quote
Should I set the file to be not hidden each time I want to read it?
It shouldn't be the problem, but worth trying.

 

TinyPortal © 2005-2018