This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Brodur's profile picture

Database/Form; help needed

Started by Brodur, 25 July 2015 - 01:46 AM
Brodur #1
Posted 25 July 2015 - 03:46 AM
So what I am trying to do is create a database program that will generate and edit customer files. I have a simple menu to select which program to run, which consists of two options, QUERY and EDIT, and launches the corresponding programs. This first part is all fairly basic and not where I'm having troubles. The problem I am running into is that I have never actually done a form in Lua, I have done some in HTML but I'm out of my depth here.

So, what I want is a program to handle viewing of a file, which will be generated for each customer. For example, I select EDIT and enter the name of the customer, an if/else goes and if the file for that customer does not exist it makes one, and opens it to be edited.

There will at this point be X fields that I would like to track:


Name: (Name of file/customer)

Membership: (Regular, VIP, VIP+)

Outstanding Orders: (A string for example: "63 cooked porkchops")

Outstanding Payments: (Another string, Ex: "3 iron ingots")

When editing I would like to only be able to edit membership, orders, and payments.

As for QUERY, I would like it to just display the fields and their values/strings after asking for the customer's name, or return an error if the file does not pass an fs.exists() check.

Just to reiterate, each customer would have their own .txt/program on the computer… unless of course someone could put this all in one, but I would like them separate to save my brain. If someone could A) walk me through the methods of trying to do this, or B)/> supply heavily annotated code; that would be great.

Any further questions as to what I want to be able to do are welcome, but I think i covered most of it in my ramble.

Thanks in advance!
Bomb Bloke #2
Posted 25 July 2015 - 08:25 AM
So, um, what was the question? Which bit has actually got you stuck - the interface, or the file IO?
Brodur #3
Posted 25 July 2015 - 04:06 PM
A little bit of all of it, I'm not really that adept a lua, I've only ever done something like this in HTML and that was from a textbook.
Grim Reaper #4
Posted 25 July 2015 - 08:22 PM
Might I point you to this tutorial on CC file IO, this tutorial on tables, and this tutorial on string patterns/string matching (this will be helpful when you're parsing your files)? Read through these and practice a little bit with them. If you've done something like this before in HTML, I bet once you have all the pieces, you'll be able to put them together.
Edited on 25 July 2015 - 06:22 PM
Brodur #5
Posted 26 July 2015 - 12:32 AM
Thanks, I'll give those a read and post back here if I still can't figure it out!