Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Oct 2008
    Posts
    51

    Grin help please for save file

    Hello all, I am again ams and not very good at English and I have a question
    I have an application with 2 pages entry and read with 1 menu in entry I have 4 input named "number" "name" "place" "quantity" and menu save idem in read.

    Help please for added code
    Thanx advance

    on show page entry
    number = Input.GetText("Input1");
    name = Input.GetText("Input2");
    place = Input.GetText("Input3");
    quantity = Input.GetText("Input4");

    on menu page entry
    if e_ID==1 then -- Item Save on menu

    --[[ script for
    Save File]]--

    result = Dialog.Message("Notice", "You have next Input.", MB_YESNO, MB_ICONINFORMATION, MB_DEFBUTTON1);
    if result == IDNO then
    Application.ExitScript();
    else
    Input.SetText("Input1", "");
    Input.SetText("Input2", "");
    Input.SetText("Input3", "");
    Input.SetText("Input4", "");

    end
    end


    on show page read
    --[[ script for Read File ]]--

    Number = Input.GetText("Input1"); -- Number introduced to Page Entry
    Input.SetText("Input2", Name); -- Read the Name in File Saved to Page Entry
    Input.SetText("Input3", Place); -- Read the Place in File Saved to Page Entry
    Input.SetText("Input4", Quantity); -- Read the Quantity in File Saved to Page Entry

  2. #2
    Join Date
    Jun 2007
    Location
    Delphi II
    Posts
    1,534

    Post Solution?

    You could do this with many different file types but I'm using an ini file for simplicity.

    --I would use this table instead of separate variables
    --I'm not entirely sure why this is in the On Show event but I'll trust that you know what you're doing
    Code:
    tblUserData = {};
    tblUserData.Number = Input.GetText("Input1");
    tblUserData.Name = Input.GetText("Input2");
    tblUserData.Place = Input.GetText("Input3");
    tblUserData.Quantity = Input.GetText("Input4");
    
    if tblUserData then
    
    	for index, item in tblUserData do
    	
    	INIFile.SetValue("AutoPlay\\Docs\\UserData.ini", "General", index, item);
    	
    	end
    	
    end
    Code:
    --Read Section (You could also read back to a table for convenience)
    Input.SetText("Input1", INIFile.GetValue("AutoPlay\\Docs\\UserData.ini", "General", "Number"));
    Input.SetText("Input2", INIFile.GetValue("AutoPlay\\Docs\\UserData.ini", "General", "Name"));
    Input.SetText("Input3", INIFile.GetValue("AutoPlay\\Docs\\UserData.ini", "General", "Place"));
    Input.SetText("Input4", INIFile.GetValue("AutoPlay\\Docs\\UserData.ini", "General", "Quantity"));
    Something like that maybe? I'm not certain what your after here.
    Last edited by Centauri Soldier; 10-19-2008 at 11:58 AM.

  3. #3
    Join Date
    Oct 2008
    Posts
    51
    thanx for the answer, it works, but when I click on Save, dialogbox asked whether the entry is complete, if not, click the new entry. inifile but took the last entry, but must add the first inifile therefore contains 2 number, 2 Name, 2 place, 2 quantity

    and on read, if the number entered on the keyboard is there then displays name, place, quantity

    thanx advance for reply

  4. #4
    Join Date
    Jun 2007
    Location
    Delphi II
    Posts
    1,534

    Huh?

    Sorry, I can't understand what you're asking for.

  5. #5
    Join Date
    Oct 2008
    Posts
    51
    Start the application in introduction to keyboard on input the number is 100, the name is ronald, the place is food, the quantity is 5 and then click menu to save and DialogBox asked whether entry finished?, whether exit application if not new entry number is 200, name is franck, place is metro, quantity is 10, click menu save etc etc if finished I have saved 1 or 2 or 3 entry etc etc.

    on read

    if I introduced on Input Numberto keyboard 100, it checks if the file exists and displays on Name ronald, on place food, on quantity 5

    if I introduced on Input Numberto keyboard 200, it checks if the file exists and displays on name franck, on place metro, on quantity 10

    etc etc

    sorry if I'm wrong but explained it is difficult for me in English

  6. #6
    Join Date
    Jun 2008
    Posts
    108
    I think you want to make a database and you have problems with the code for the inifile
    Code:
    --Read Section (You could also read back to a table for convenience)
    Input.SetText("Input1", INIFile.GetValue("AutoPlay\\Docs\\UserData.ini", "General", "Number"));
    Input.SetText("Input2", INIFile.GetValue("AutoPlay\\Docs\\UserData.ini", "General", "Name"));
    Input.SetText("Input3", INIFile.GetValue("AutoPlay\\Docs\\UserData.ini", "General", "Place"));
    Input.SetText("Input4", INIFile.GetValue("AutoPlay\\Docs\\UserData.ini", "General", "Quantity"));
    because this only stores ONE set of data, but you want to store more than one set.

    If the numbers (100, 200) are somethink like customer- numbers, you can put them in a variable to declare the section of the ini-file.

    if the Number is in the variable number, the Name the variable name, the Place the variable place and the Quantity the variable quantity, you put it like this:
    Code:
    number = Input.GetText("Input1");
    name = Input.GetText("Input2");
    place = Input.GetText("Input3");
    quantity = Input.GetText("Input4");
    
    INIFile.SetValue("AutoPlay\\Docs\\UserData.ini", number, "Name", name);
    INIFile.SetValue("AutoPlay\\Docs\\UserData.ini", number, "Place", place);
    INIFile.SetValue("AutoPlay\\Docs\\UserData.ini", number, "Quantity", quantity);
    But i think it´s easier to work with the sqlite plugin.
    There are a lot of examples that you can use.

    Ini-files are more for storing parameters.
    If you work with sets of data, they are really not the best choice.
    Last edited by presidente; 10-19-2008 at 05:22 PM.

  7. #7
    Join Date
    Oct 2008
    Posts
    51
    thanx for reply, but wat is plugin sqlite

    I'm open for more suggestion, if is easy good for nexbies thanx

  8. #8
    Join Date
    Jun 2007
    Location
    Delphi II
    Posts
    1,534
    If that's what you're after you may also benefit from the DataBase Action Plugin...search the forums and you'll find tons of plugins.

    You may consider using an xml file for your program as well.

    I understand how it is to be new to AMS as I was new to AMS a while ago too. I spent hours upon hours reading the AMS help file...I highly recommend it. You're going to find many of your answers in that file.

  9. #9
    Join Date
    Oct 2008
    Posts
    51
    ok thank you I look on plugin, but I think I come back to you thank you

  10. #10
    Join Date
    Oct 2008
    Posts
    51
    I find an example sqlite (customer v5) create by stickck.
    I'm modified this code by adapted in my application, but when you start the application I get an error " On preload, line 14:First argument to SQLite.QueryToTable() must be a database handle.
    Help please

    code by stickck
    function FillCustomer_List()
    --%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%
    -- Clear contents of all items on the page
    --%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%
    ListBox.DeleteItem("Name_List", -1);
    Input.SetText("Total input", "");
    Input.SetText("Search", "");
    Input.SetText("Customer_info", "");

    --%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%
    -- Query table DVD_List and store all entries in table tWebsites
    --%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%
    tInfo_List = SQLite.QueryToTable(db, "SELECT * FROM Info_List");
    nLastError = Application.GetLastError();
    if nLastError ~= SQLite.OK then
    Dialog.Message("Error", SQLite.GetLastErrorString());
    end

    --%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%
    -- if there were no errors, continue, otherwise do nothing
    --%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%
    if nLastError == SQLite.OK then
    --traverse the table
    for nRow = 1,tInfo_List.Rows do
    --get the title of the current record
    sName = tInfo_List.Data[nRow]["Name"];
    --add the item to the listbox with text = title and data = row number (in table)

    --************************************************** ******************use the RecordID INSTEAD of the Row Number
    ListBox.AddItem("Name_List", tInfo_List.Data[nRow]["Name"], tInfo_List.Data[nRow]["RecordID"]);

    end
    end
    end

    FillCustomer_List();

    ---------------------------------------------------------------

    My change is the character in red

    code modified for me
    Date = System.GetDate(DATE_FMT_EUROPE);
    function FillCustomer_List()
    --%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%
    -- Clear contents of all items on the page
    --%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%
    ListBox.DeleteItem("Name_List", -1);
    Input.SetText("Total input", "");
    Input.SetText("Search", "");
    --Input.SetText("Customer_info", "");

    --%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%
    -- Query table DVD_List and store all entries in table tWebsites
    --%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%
    tInfo_List = SQLite.QueryToTable(db, "SELECT * FROM Info_List");
    nLastError = Application.GetLastError();
    if nLastError ~= SQLite.OK then
    Dialog.Message("Error", SQLite.GetLastErrorString());
    end

    --%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%
    -- if there were no errors, continue, otherwise do nothing
    --%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%
    if nLastError == SQLite.OK then
    --traverse the table
    for nRow = 1,tInfo_List.Rows do
    --get the title of the current record
    sNumero = tInfo_List.Data[nRow]["Numero"];
    --add the item to the listbox with text = title and data = row number (in table)

    --************************************************** ******************use the RecordID INSTEAD of the Row Number
    ListBox.AddItem("Name_List", tInfo_List.Data[nRow]["Numero"], tInfo_List.Data[nRow]["RecordID"]);

    end
    end
    end

    FillCustomer_List();

Similar Threads

  1. Example: Searching file in fixed drives
    By autoplmst6 in forum AutoPlay Media Studio 7.5 Examples
    Replies: 11
    Last Post: 08-01-2009, 04:21 AM
  2. Searching for a file and overwrite it with docs file
    By Wonderboy in forum AutoPlay Media Studio 6.0
    Replies: 32
    Last Post: 03-23-2006, 06:59 AM
  3. HOWTO: Create a File Association
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 10-04-2002, 02:37 PM
  4. Can search allow manual browse even if file is found?
    By RichardShaw in forum Setup Factory 5.0
    Replies: 2
    Last Post: 08-28-2000, 06:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts