Hello again,
I'm using the "Read from text file" action to read the magic out of the first line from the licensefile.
(I want to check if the licensefile is really a good one, after that the license file will be copied to the installationdir.)
So I only have to read the first line into a variable.
The file has to be closed after this.
Then I ((think I)) have 2 options to close the file.
1. Loop to read the whole file waiting at end of file:
label
Read Line
if not eof
goto label
(Not really nice when having a very big text file to read, but workable for me.)
2. Open a textfile what does not exist before opening the textfile. (again)
Number 2 is'nt a really nice option too.
Is there any better option to close the file?
Thanks!
Closing text file
-
MichaelNesmith
- Posts: 3452
- Joined: Thu Dec 22, 2005 7:17 pm
- Contact:
There should be no need to explicitly close a file...but I would recommend the reading from invalid file option as the quickest and easiest (and safest method, too!)
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
Michael,
I really!! need to close that file.
Here is the situation:
The user selects the licensefile.
I check the first row for the magic key to check if it is a good licensefile.
The first row is put in a variable, the variable will be checked if it has the right number etc.
the user goes forward and then back because he thinks he selected the wrong licensefile. But that wasn't true so he selects the same file as before
Because the file is still open, the command "read from text file" reads the SECOND line of the file. And there is no magic key.
So the variable will filled with wrong information and the test fails.
The invalid file works perfectly but it's not a really clean and nice option so I thought lets ask.
I really!! need to close that file.
Here is the situation:
The user selects the licensefile.
I check the first row for the magic key to check if it is a good licensefile.
The first row is put in a variable, the variable will be checked if it has the right number etc.
the user goes forward and then back because he thinks he selected the wrong licensefile. But that wasn't true so he selects the same file as before
Because the file is still open, the command "read from text file" reads the SECOND line of the file. And there is no magic key.
So the variable will filled with wrong information and the test fails.
The invalid file works perfectly but it's not a really clean and nice option so I thought lets ask.
-
MichaelNesmith
- Posts: 3452
- Joined: Thu Dec 22, 2005 7:17 pm
- Contact:
Yeah, I understand! Don't worry invalid file is actually clean. No harm is done when file open fails - the setup engine checks for error conditions and handles them correctly.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
Read From Text File - Label issue
Can you clarify what you are referring to by "reading from invalid file option"?
Is this a built-in command or a plugin i can download from somewhere?
I also have a problem with the "Read From Text File" command--I use it as follows to "Refresh" the list of databases available on a particular SQL database server:
<pseudocode>
Get Temporary File to TMP_DATABASES
Run Program OSQL -Q "SELECT name FROM master.dbo.sysdatabases" -o $TMP_DATABASES$
label: Read Database Names
Read from Text File $TMP_DATABASES$ into Variable READ (get EOF into EOF)
if Variable EOF Equals FALSE
// Do processing work, line-by-line
GoTo label: Read Database Names
end
<problem>
I want this block to be reusable inside and "Include script" because i need to do this more than once. Because the only way to read from a text file all the way is to use a "Label", my project won't compile with the following error:
---------------------------
Compile Error
---------------------------
LABEL re-defined: Read Database Names from server
---------------------------
OK
---------------------------
I see there is a "Wizard Loop" command, but it can only be used with "Show Dialog".
Is there *any* possibility that reading through a (non-.ini) text file can be done without using the label statement? (perhaps a "Loop" and "LoopExit" command?)
thanks!
Is this a built-in command or a plugin i can download from somewhere?
I also have a problem with the "Read From Text File" command--I use it as follows to "Refresh" the list of databases available on a particular SQL database server:
<pseudocode>
Get Temporary File to TMP_DATABASES
Run Program OSQL -Q "SELECT name FROM master.dbo.sysdatabases" -o $TMP_DATABASES$
label: Read Database Names
Read from Text File $TMP_DATABASES$ into Variable READ (get EOF into EOF)
if Variable EOF Equals FALSE
// Do processing work, line-by-line
GoTo label: Read Database Names
end
<problem>
I want this block to be reusable inside and "Include script" because i need to do this more than once. Because the only way to read from a text file all the way is to use a "Label", my project won't compile with the following error:
---------------------------
Compile Error
---------------------------
LABEL re-defined: Read Database Names from server
---------------------------
OK
---------------------------
I see there is a "Wizard Loop" command, but it can only be used with "Show Dialog".
Is there *any* possibility that reading through a (non-.ini) text file can be done without using the label statement? (perhaps a "Loop" and "LoopExit" command?)
thanks!
drew
Currently Using: Install Aware Studio, v6.42 (SP2)
Currently Using: Install Aware Studio, v6.42 (SP2)
-
MichaelNesmith
- Posts: 3452
- Joined: Thu Dec 22, 2005 7:17 pm
- Contact:
Just call Read from Text File, and specify an invalid file name that doesn't exist. This will close the currently open file and will not raise an error when it fails to open the new file.Can you clarify what you are referring to by "reading from invalid file option"?
Not clear on this one here...are you including the same script multiple times? I don't see why using this from an include script would be a problem.LABEL re-defined: Read Database Names from server
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
Yes, i was wanting to use "Include Script" multiple times -- that is specifically what causes the problem. For now, I can workaround the issue by just repasting the necessary code multiple times in my main script and renaming the label to be unique each time i need to perform this task.Not clear on this one here...are you including the same script multiple times? I don't see why using this from an include script would be a problem.
Example:
Load a list of databases,
User installs a clean database,
I need to refresh the database list to make sure the new database now shows up in the list.
sorry about the confusion,
thanks so much for your prompt reply![/quote]
drew
Currently Using: Install Aware Studio, v6.42 (SP2)
Currently Using: Install Aware Studio, v6.42 (SP2)
-
MichaelNesmith
- Posts: 3452
- Joined: Thu Dec 22, 2005 7:17 pm
- Contact:
I would keep the label and the goto statement outside of the include script. That way you can process the bulk of the task within the include script, and loop the actual task outside of it. Might that help?
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
No -- The *whole* of my task *is* the reading and parsing of the file. (which necessitates the label and the goto). There's no "bulk" of the work that can be moved out.MichaelNesmith wrote:I would keep the label and the goto statement outside of the include script. That way you can process the bulk of the task within the include script, and loop the actual task outside of it. Might that help?
Fwiw, I'm needing to get part of a WiseScript package rewritten:
It uses something like an "Include Script" from Wise in order to repeat running a SQL query and parsing the output from the query out of a temp file many times; However, it relies on their "While loop" statement when reading from a file, so it doesn't have a problem with duplicate labels.
Are there any plans for a control statement besides IF/ELSE that would make tasks like this much easier to complete without using labels?
The only workaround i have at this point is to paste in the same code over and over again, and additionally go edit each label to be unique so that i can compile. Unfortunately, the parsing and reading of the file is more than a few lines so it quickly becomes a problem to manage in my main installation script.
If there are any other workarounds you can think of, let me know.
Thanks again for your help
drew
Currently Using: Install Aware Studio, v6.42 (SP2)
Currently Using: Install Aware Studio, v6.42 (SP2)
-
MichaelNesmith
- Posts: 3452
- Joined: Thu Dec 22, 2005 7:17 pm
- Contact:

