ExtractPath includes trailing parentheses

Got a problem you cannot solve? Try here.
Post Reply
ulrichard
Posts: 150
Joined: Thu Dec 27, 2007 5:45 am
Location: Switzerland
Contact:

ExtractPath includes trailing parentheses

Post 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 ;-)
http://www.pointline.com
http://www.paraeasy.ch
http://ulrichard.ch
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Re: ExtractPath includes trailing parentheses

Post by MichaelNesmith »

Can you give the debugger output of variables as you are stepping through this code?
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
ulrichard
Posts: 150
Joined: Thu Dec 27, 2007 5:45 am
Location: Switzerland
Contact:

Re: ExtractPath includes trailing parentheses

Post 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
http://www.pointline.com
http://www.paraeasy.ch
http://ulrichard.ch
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Re: ExtractPath includes trailing parentheses

Post 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.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
ulrichard
Posts: 150
Joined: Thu Dec 27, 2007 5:45 am
Location: Switzerland
Contact:

Re: ExtractPath includes trailing parentheses

Post 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
http://www.pointline.com
http://www.paraeasy.ch
http://ulrichard.ch
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Re: ExtractPath includes trailing parentheses

Post 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.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
ulrichard
Posts: 150
Joined: Thu Dec 27, 2007 5:45 am
Location: Switzerland
Contact:

Re: ExtractPath includes trailing parentheses

Post 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?
http://www.pointline.com
http://www.paraeasy.ch
http://ulrichard.ch
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Re: ExtractPath includes trailing parentheses

Post 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.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
Post Reply