Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2006
    Posts
    346

    Save from input to cfg, bat etc..

    Hello all,

    I would like to have a few button that will save all the text from an input object and save with diffrent extension such as, bat, cfg & inf. The code below is what I'm currently using and works. I want to elimate the file browse and just save with the correct extension.

    I have a drop down that populates 5 files with different extensions. I have 5 buttons that are hidden and show when the current text is populated. How can I change this code to save as the right extension with out the file browse. Hope this makes sense - Thanks

    Code:
    -- Prompt the user for a location to save to
    sSaveFileName = Dialog.FileBrowse(false, "Save", "C:\\ZFDAGENT", "bat (.bat)|.bat|", "zfd.bat", "bat", false, false)[1];
    
    -- Get the paragraph properties
    tProperties = Input.GetProperties("Input1");
    
    -- Get the currently displayed text
    sText = tProperties.Text
    
    -- Output the text to a file
    TextFile.WriteFromString(sSaveFileName, sText, false);

  2. #2
    Join Date
    Aug 2003
    Posts
    2,427
    I might not have understood correctly but it sounds like you have already got a file name and you are using a combo box to select a filename extension which you want to concatenate into the complete filename, in which case something like -

    Code:
    sel = ComboBox.GetSelected("ComboBox1");
    ext = ComboBox.GetItemText("ComboBox1", sel);
    -- or ComboBox.GetItemData if appropriate 
    stext = "existing file name"
    sSaveFileName = stext..ext

  3. #3
    Join Date
    Feb 2006
    Posts
    346
    I have attached project.

    I have some files (bat, cfg, txt & inf) that get copied to local pc. I want the end user to be able to edit these files and be able to click save and it save the data from the input object to the correct location on local PC with out prompting for a location to save to. Hope that makes better sense! thanks
    Attached Files

  4. #4
    Join Date
    Aug 2003
    Posts
    2,427
    Quote Originally Posted by abnrange View Post
    I want the end user to be able to edit these files and be able to click save and it save the data from the input object to the correct location on local PC with out prompting for a location to save to.
    Is the correct location always the same? Is it C:/ZFDAGENT in which case you need to add some code in to check if it exists and create it if not.

  5. #5
    Join Date
    Feb 2006
    Posts
    346
    The files are in different locations on c:\. The only solution I could come up with was to have several save buttons each having the dialog browse which I would like to elimate. The below code works for txt files but not cfg, bat inf etc. Is there away to make the below code work? Thanks

    Code:
    TextFile.WriteFromString("c:\\ZFDAGENT\ZFD.bat", new_contents, false);
    result = Dialog.Message("Notice", "File Saved!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

  6. #6
    Join Date
    Aug 2004
    Location
    Somewhere in Texas, USA
    Posts
    417
    The more I read this thread the more lost I become.

  7. #7
    Join Date
    Aug 2003
    Posts
    2,427
    I'm afraid I'm lost too - why not just rename the file?

  8. #8
    Join Date
    Feb 2006
    Posts
    346
    Sorry for all the confusion. What I would like to do is allow the end user to load a bat, cfg txt and inf files in to an iput object. The files are in different location on c:. Then, the end user can modify the files and just click a save button and the file is saved back in the orginal location with the correct extension. Thanks

  9. #9
    Join Date
    Feb 2006
    Posts
    346
    I finally figured it! Thanks

    Code:
    ---- The string to save
    new_contents = Input.GetText("Input1");
    
    -- Write out the modified contents of the text file.
    TextFile.WriteFromString("c:\\zfdagent\\zfd.bat", new_contents, false);
    result = Dialog.Message("Notice", "File Saved!", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

Posting Permissions

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