PDA

View Full Version : insert a lot of data in a table



coffeeworm
12-03-2003, 05:58 PM
How can I insert a lot of data in a table in design time?
:( But not key in all data individually.
e.x. I have a 1000 details data as a *.txt,
How can I do?:confused:

Corey
12-03-2003, 06:29 PM
Hi. Try TextFile.ReadToTable();

Let us know if that works for your scenario... :)

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

coffeeworm
12-03-2003, 10:13 PM
Hi,Corey Thanks for your response.
But,I mean that what I told above is during the Design Time,not the Run Time.What I Wanna do is building a lot values, such as serial numbers in a table.Can I check whether he/she has rights to use my application.

Corey
12-04-2003, 12:04 AM
Well with some clever work in your favorite advanced text editor you could probably prepare something you could paste into the script editor.

OR

You could do my very favorite thing I use AMS for. Build a tool to do it for you. :) Build a tool which reads in your serials from a text file (I assume you have aggregated the data somewhere) and re-formats it as appropriate for cut and paste into the script editor. Then in the future you can turn a serial list into a design time code paste in 5 seconds. :)

So in other words, if you have a file that goes:

91876543
jh43luiy5
li256980X
kj3h65489

You would want to re-format it to say:

Table.Insert(table_name, 1, "91876543");
Table.Insert(table_name, 2, "jh43luiy5");
Table.Insert(table_name, 3, "li256980X");
Table.Insert(table_name, 4, "kj3h65489");

Then you could just paste it in.

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

Lorne
12-04-2003, 12:10 AM
No need to use the actions. Much better/faster to just initialize the table, like so:


table_name = {1, "91876543", 2, "jh43luiy5", 3, "li256980X", 4, "kj3h65489" }

With a good text editor, you can easily convert a huge text file into such a table initialization using a simple search and replace. (Or, as Corey suggested, build an AutoPlay app to do it.)

Doesn't have to be all on one line, either...you can format it like this if you prefer:


table_name = {1, "91876543",
2, "jh43luiy5",
3, "li256980X",
4, "kj3h65489"}

Or like this:


table_name = { 1, "91876543"
, 2, "jh43luiy5"
, 3, "li256980X"
, 4, "kj3h65489"
}

Corey
12-04-2003, 12:14 AM
Yeah, that's way better. Not sure what I was thinking.

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

Stefan_M
12-04-2003, 12:22 AM
Hi coffeeworm,

make a <serial.lua> file and include the action
dofile(_SourceFolder.."\\Autoplay\\Scripts\\serial.lua");
in project - action "On Startup"

serial.lua
--create table
name={}
serial={}

name[1]="hugo"
serial[1]="1234"
name[2]="franz"
serial[2]="2345"
name[3]="tom"
serial[4]="3456"
--and so on

you can make a AMS program that
parse the text file and write it to the .lua file
functions:
TextFile.ReadToTable();
TextFile.WriteFromTable;

hope this helps

Stefan

coffeeworm
12-04-2003, 02:31 AM
Thanks all response,but A script file(.lua) is simply a text file containing AutoPlay script.
If I do what you say,all user can ckeck it out use any texteditor.
It's meaningless for authorization.

Corey
12-04-2003, 02:38 AM
Hi. Just use the text editor purely to prepare the code for pasting, but as I mentioned you would cut and paste that code into your project. No text file ever exists, you just use the text editor as a tool to format the text for pasting into AMS. Lorne's post outlines the best format...

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

Stefan_M
12-04-2003, 02:43 AM
Ok

why not copy all lines from the *.lua file to project - actions "On Startup" instead of including it.

All you have to do bevor is convert your textfile into Scriptfile format.

Make project that do this for you.

Send me a Demo.txt with some serial numbers and the table definitions which you want to use and I will make you a simple demo program.

Stefan

coffeeworm
12-04-2003, 05:44 PM
Hi Stefan,
Thanks for your help,I can offer you a demo.txt consisting of 100 serial numbers.
I want to build the serial numbers in a table named as "Serial" in my application, however,my users can't check them out by any way.

Stefan_M
12-04-2003, 11:42 PM
Hi,

a simple way is to do it with excel.
An excel sheet shows how to create the lines needed in the Script.
Take a look at the project. Open "Project - actions <On Startup>
The lines 3 to 102 are simple copied from the excel sheet.



Stefan

coffeeworm
12-05-2003, 12:04 AM
Thanks! Stefan:)