Page 1 of 1

ExtractPath includes trailing parentheses

Posted: Tue Jun 22, 2010 1:34 am
by ulrichard
What's wrong with the following code?

Code: Select all

Find All Files in path C:\Program Files (x86)\PointLine21\UserDat\lic\*.lic (include subfolders), write result into variable LicenseNames
Set Variable LicTmpName to 
Parse String $LicenseNames$ into Variables LicTmpName and LicenseNames (Split at first occurrence of pattern)
Extract Full File Name: LicTmpName
MessageBox: inspect variable, LicTmpName = $LicTmpName$
It assumes that the "Extract Full File Name"(ExtractPath) command contains actual filesystem logic (like e.g. boost::filesystem), not just a single string operation.
The variable LicTmpName contains the trailing parentheses. I have to manually remove them to use the filename afterwards. This led to a bug that took a bit of work to find.
I think that should be done in the "Extract Full File Name"(ExtractPath) path command. (Or the command be renamed to ReturnEverythingAfterTheLastBackslash ;-)

Re: ExtractPath includes trailing parentheses

Posted: Tue Jun 22, 2010 3:51 am
by MichaelNesmith
Can you give the debugger output of variables as you are stepping through this code?

Re: ExtractPath includes trailing parentheses

Posted: Tue Jun 22, 2010 5:42 am
by ulrichard
Hi Michael,

sure...

Code: Select all

Find All Files in path C:\Program Files (x86)\PointLine21\UserDat\lic\*.lic (include subfolders), write result into variable LicenseNames
LicenseNames="C:\Program Files (x86)\PointLine21\UserDat\lic\default\PointLine3D.lic"|"C:\Program Files (x86)\PointLine21\UserDat\lic\floating\PointLine3D.lic"

Code: Select all

Set Variable LicTmpName to
Parse String $LicenseNames$ into Variables LicTmpName and LicenseNames (Split at first occurrence of pattern)
LicenseNames="C:\Program Files (x86)\PointLine21\UserDat\lic\floating\PointLine3D.lic"
LicTmpName="C:\Program Files (x86)\PointLine21\UserDat\lic\default\PointLine3D.lic"

Code: Select all

Extract Full File Name: LicTmpName
LicTmpName=PointLine3D.lic"

what I would expect is:
LicTmpName=PointLine3D.lic


Rgds
Richard

Re: ExtractPath includes trailing parentheses

Posted: Tue Jun 22, 2010 3:14 pm
by MichaelNesmith
Ah, I see what you mean. So it is an issue of the trailing quote. You will want to remove those explicitly using Replace String before making a call to Extract Path. Extract Path does not analyze quotes but analyzes back-slashes only. Since Find All Files wraps return values inside double quotes, you will need to take them out before further processing.

Re: ExtractPath includes trailing parentheses

Posted: Wed Jun 23, 2010 12:24 am
by ulrichard
Yes, Replace String was what I did in the end. But it's a bit counter intuitive, that's why I report it here.
"Extract Full File Name" sounds like it's aware of what it deals with. Instead it's just a simple find and substring operation.
In contrast other filesystem abstractions like boost::filesystem deal with these things.
Handling with filenames has so many special cases, and if one has to handle these manually, there's not much point in using provided functions that I don't know which ones they handle and which ones not. If the command doesn't care about the special cases, then ReturnEverythingAfterTheLastBackslash might be a better name for it.
It's not something that needs an urgent fix, but I think other users could benefit if potential problems are taken care of for them.
For the moment I work around the problem, but in the long run I prefer to have them fixed at the root. Be it for version 10 or 11...

Rgds
Richard

Re: ExtractPath includes trailing parentheses

Posted: Wed Jun 23, 2010 1:25 am
by MichaelNesmith
Actually the long term plan is to have commands like Find All Files start a processing loop all on their own (like while...end) :) So there would be even less parsing for you to do in the script.

Re: ExtractPath includes trailing parentheses

Posted: Wed Jun 23, 2010 1:46 am
by ulrichard
That sounds good. Does that mean real while and for loops, so that we no longer have to do loops with goto's?
Do you have a teaser to show?

Re: ExtractPath includes trailing parentheses

Posted: Wed Jun 23, 2010 4:23 am
by MichaelNesmith
Yes, these will be coming in the InstallAware 11 time frame. Loops did not make sense for as long as we did not have our own native setup engine - because only the last iteration of each loop could be executed by MSI. Now this restriction is being removed by InstallAware 10.