Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 11 of 11
  1. #1
    Join Date
    Jun 2007
    Posts
    6

    help with save as

    Hello im quite new to AMS. Im in progress of making a simple program and iv got to the point where I would like to make a "Save as" button. So far iv been experimenting with a blank project. I have created a button which creates a table, I then created a button that displays the first value (255) from the table in a dilog box (just to make sure it works). Then iv got a "save as" button and a "open" button. ANYWAY! When i preview the program i insert the table, click the "save as" and call it something like test and the file test appers! yay but when i open it back up again the table value has changed from 255 to the location i saved the file to? eg C:\test.dat

    Make table button:
    myArray = {255,0,255};

    Get first value button:
    Dialog.Message("First number", myArray[1], MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

    Save As button:
    myArray = Dialog.FileBrowse(false, "Save As", "C:\\", "All Files (*.*)|*.*|", "", "dat", false, true);
    TextFile.WriteFromTable(myArray[1], myArray, false);

    open button:
    myArray = Dialog.FileBrowse(true, "Locate File", "c:\\", "All Files (*.*)|*.*|", "", "", false, true);

    Thanks

  2. #2
    Join Date
    Jun 2007
    Posts
    6
    Nobody wants to help me?

  3. #3
    Join Date
    Feb 2001
    Location
    Indigo Rose Software
    Posts
    2,728
    You're putting the value returned from Dialog.FileBrowse into myArray, which doesn't make sense.
    Last edited by Lorne; 06-27-2007 at 10:16 AM.
    --[[ Indigo Rose Software Developer ]]

  4. #4
    Join Date
    Nov 2006
    Posts
    233
    The file browse also returns a table as its result so you have to specify you want the first entry in that table.

    Either try this code or have a look at the example I've posted..
    Code:
    --Make Table
    myArray = {255,0,255};
    
    --Get first value button:
    Value = myArray[1];
    Dialog.Message("First number", Value, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    
    --Save As button:
    SaveAs = Dialog.FileBrowse(false, "SaveAs", "C:\\", "All Files (*.*)|*.*|", "", "dat", false, true);
    TextFile.WriteFromString(SaveAs[1], Value, false);
    
    --open button:
    Open = Dialog.FileBrowse(true, "Locate File", "c:\\", "All Files (*.*)|*.*|", "", "", false, true);
    File.Open(Open[1], "", SW_SHOWNORMAL);
    just remember when you declare a variable then it is declared "GLOBALLY" so dont use the same variable names over and over
    Attached Files
    Last edited by Desrat; 06-27-2007 at 10:01 AM.

  5. #5
    Join Date
    Jun 2007
    Posts
    6
    Thankyou for your replys. Sorry for my stupidity. Iv got it so save what i want now! the only thing is im a little unsure how im going to do the next thing i want to do!

    If i was to save a file with the text: all = {1,2,3};
    Would it be possible to open and insert the table into some script?

  6. #6
    Join Date
    May 2006
    Posts
    5,380
    Would it be possible to open and insert the table into some script?

    you would need to format your text file like, eg:

    1
    2
    3

    with each new item on a new line, and use Text.ReadToTable
    Open your eyes to Narcissism, Don't let her destroy your life!!

  7. #7
    Join Date
    Jun 2007
    Posts
    6
    Cool thanks! I tried that before but didnt work now it does though!
    ok iv got one more question I hope! Is it possible to set text in a paragraph but no over write existing text instead start a new line?

    example:

    first set.text command "hello"

    will diplay:
    hello

    second set.text command "how are you?"

    will display:
    hello
    how are you?
    Last edited by Dangerscott2020; 06-30-2007 at 12:00 PM.

  8. #8
    Join Date
    Jun 2002
    Location
    Israel
    Posts
    1,843
    Simple enough:
    yourText = Paragraph.GetText("yourParagraph");
    newText = "/r/nwhatever you want to add";
    --new text begining on a new line
    yourText = yourText..newText;
    Paragraph.SetText("yourParagraph", yourText);

    Good luck
    Yossi

  9. #9
    Join Date
    Jun 2007
    Posts
    6
    ah i c thanks
    ok got another one for you chaps! Sorry!
    Is it possible to declare a variable to a element in a table?

    example: all = {1,2,3};

    all[1] = hello

    i tried this but didnt seem to work

  10. #10
    Join Date
    May 2006
    Posts
    5,380
    nearly right, but in this case you would need to declare a empty table and add the values, the way you have it "1" would already be assigned to "all[1]" and "2" to all[2] and so forth, also, you have to wrap all text in double quotes ("")

    try it like this
    all = {}
    all[1] = "hello"
    all[2] = "good bye"
    all[3] = "hello again"

    you can of course assign anything you like to a already existing table element, the way you have it should work as its just changing the table element contents, but if you dident quote the text it would not work

    hope that helps
    Open your eyes to Narcissism, Don't let her destroy your life!!

  11. #11
    Join Date
    Jun 2007
    Posts
    6
    chears mate, got it to work.
    got some more thinking to do now!

Similar Threads

  1. click button to save file - opens up save window...
    By cityofsalisburync in forum AutoPlay Media Studio 5.0
    Replies: 0
    Last Post: 11-10-2006, 08:43 AM
  2. Save As Doesnt Save Anything
    By nigeldude in forum AutoPlay Media Studio 6.0
    Replies: 0
    Last Post: 05-19-2006, 02:03 AM
  3. Displaying a Save As Dialog
    By Desmond in forum AutoPlay Media Studio 5.0 Examples
    Replies: 0
    Last Post: 10-01-2003, 03:53 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