PDA

View Full Version : I just don't get it


pher
08-24-2008, 11:22 PM
I really like the simplicity of this product in many areas. However, there is a massive disconnect between me and the product in other areas.

For the life of me, I've been unable to figure out how to do some things that seem rather simple. I've reviewed all the video tutorials, and read all that I could find on the forums, but I still haven't found the answer.

So, here I am with what I hope is something really simple that makes me feel extremely foolish.

I want to create an installer that does the following On Post Install, prior to the finish screen:

1. Allow the user to browse to a file on their hard drive (I store this file location as a session variable).

2. I then modify a text file (configuration file) with the value of the path specified in the step above.

That's it.

Any help would be massively appreciated.

upeters
08-24-2008, 11:37 PM
Please show what you have in On Post Install, because with it it is easier to point out what you are doing wrong.

Ulrich

pher
08-25-2008, 07:35 AM
That's just it... I've not made much progress in that area.

I've created an Edit Fields screen.

I have the following:

Screen ID: Server Logs
ID: CTRL_EDIT_01
Label: Location of server logs:
Show button: enabled
Session Variable: %EditVar01%

Everything else is default.

I have nothing in the Actions, simply because I don't know what to put there.

Here's what I want:

I want the button '...' at the end of the input box to open a file dialog window which allows the user to browse to a file in their directory.

Upon selecting that file and clicking the 'Next' button, I want to open a settings file in my installation directory and replace a placeholder value with the %EditVar01% value.

On Post Install has the following:
result = Dialog.FileBrowse(true, "Locate Server Log", _DesktopFolder, "Log Files (*.log)|*.log|", "", "log", false, true);

I don't know what to put for Event Variables.

When I run the install, it immediately opens a file dialog box without bringing me to the Server Logs screen. When I select the file, the install shuts down and all windows are closed. I need the file dialog box to only open when the button on the screen is pressed.

pher
08-25-2008, 08:53 AM
Ok, I've managed to get it to not terminate the setup when the file dialog window is closed, however, I still haven't figured out how to bind the button click event to the open file dialog.

pher
08-25-2008, 09:47 AM
I'm starting to make some progress.

I was able to figure out the eventid for the button press...

So, I have the following code on my 'On Ctrl Message' actions:


if(e_CtrlID == 121) then

-- Browse
result = Dialog.FileBrowse(true, "Locate Server Log", _DesktopFolder, "Log Files (*.log)|*.log|", "", "log", false, true);

-- Debug - spit out the filename we found to a messagebox
Dialog.Message("file", result[1], MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

-- Replace placeholder value with file path
-- local sFileData = TextFile.ReadToString("%AppFolder%\\settings.txt");
-- sFileData = String.Replace(sFileData, "%PlaceHolder%", result[1], true);
-- TextFile.WriteFromString("%AppFolder%\\settings.txt", sFileData, false);
end


I've not been able to figure out how to set the filepath I've now stored in my result to the control on the installer.

Also, I've not tested the replace code...

Mark
08-25-2008, 09:48 AM
Hi pher,

If you want to browse for a file on the Edit Fields screen, what you can do (in general) is enable the first edit field's button and then add the following code to the "On Ctrl Message" event of the Edit Fields screen:


if ((e_CtrlID == CTRL_BUTTON_01)
and (e_MsgID == MSGID_CLICKED)) then
--The first edit ctrl's button was clicked.

local tbEditProps = DlgEditField.GetProperties(CTRL_EDIT_01);
if(not tbEditProps) then
-- The edit field is not accessible or does not exist
return;
end
-- browse for the server log
result = Dialog.FileBrowse(true, "Locate Server Log", _DesktopFolder, "Log Files (*.log)|*.log|", "", "log", false, true);
-- if the result if valid then update the edit field

if((result ~= nil) and (result[1] ~= "CANCEL")) then
--get the first selected file
tbEditProps.Text = result[1];
--update the edit field
DlgEditField.SetProperties(CTRL_EDIT_01, tbEditProps)
end
end


In general what you are doing is responding to the MSGID_CLICKED event that is sent by the CTRL_BUTTON_01 button control when it is clicked. Then you get the current properties of the edit field, so that you can then update the edit fields properties later on.

Next comes the browse code to browse for the file. Then we check to see if the result is valid. If it is valid we update the Text portion of the edit field's propertied and update the edit field.

Then on the "On Next" event you should be able to write the expanded version of "%EditVar01%" to you settings file.

I hope this helps.