Page 1 of 1

How do I get a persisted variable from previous install?

Posted: Thu Oct 24, 2013 11:09 am
by JohnO
When I install a new version of an existing app, the uninstall-before-install processing somehow knows where the current version is installed, and uninstalls it from there. How does it know the location of the current version?

The reason I ask is that I have a new variable called USERWORKSPACE, which I persist. If I explicitly uninstall the current app, the value that the user chose is saved and used again (in the same way that $TARGETDIR$ is known).

However, when I am installing a new version 'over' an existing one, i can see from debug MessageBoxes, that neither TARGETDIR nor USERWORKSPACE have been set to their values that were persisted in the old setup. This suggests that the current value of TARGETDIR is persisted somewhere else - the Registry? If it is, could you give me a clue as to where to look in the MSIcode to see it saved and recovered. I need to do something similar for USERWORKSPACE

Regards, John

Re: How do I get a persisted variable from previous install?

Posted: Thu Oct 24, 2013 11:57 am
by FrancescoT
Dear John,

Please have a look at the following topic;
http://www.installaware.com/forum/viewt ... f=2&t=1734

Anyway, I am sure there are available even more topic about the same argument on the forum.

Regards

Re: How do I get a persisted variable from previous install?

Posted: Fri Oct 25, 2013 2:23 pm
by JohnO
Dear Francesco
I have used Save Feature to persist my USERWORKSPACE and other values into AppData\$PRODUCTCODE$\ia_memento.txt.
However I am stuck when it comes to getting them back! I expected Load Feature to populate any persistent variables that were already defined from the saved text file. However when I display values after the Load, TARGETDIR = it's default value, and USERWORKSPACE is empty.

In the help for Load Feature Selections, it says:
Selection states will be ignored for all features not explicitly defined in the setup script using the Define Component command by the time the Load Feature Selections command executes in the script.
My trouble is that I don't understand what I am supposed to define here, and how it relates the Load Feature Selections - there is no reference in the Save or Load command to a feature.

I added a Define Component for my 'root' feature, then loaded my txt file. This made no difference. It seems to me that I need a command to load and extract the variables that I need.

Are there any examples of saving and getting the persistent variables in this way. I seem to be so close...

[edit:
I found someone having exactly the same problem back in May:
http://www.installaware.com/forum/viewt ... f=2&t=9467
But that ended without a resolution. I seems to me that there is a need for an example of how to code this (save and retrieve), but it doesn't seem to exist. Could you or someone provide example of the code statements?
]

Regards, John

Re: How do I get a persisted variable from previous install?

Posted: Mon Oct 28, 2013 1:47 am
by JohnO
I've now come to the conclusion that the easiest way to achieve this is to save and read the values in an ini file.

However, given that there looks to be a lack of info on how to use Load Feature Selection, it would be very helpful if this thread could be completed by some guidance.

John

Re: How do I get a persisted variable from previous install?

Posted: Mon Oct 28, 2013 10:58 am
by FrancescoT
Dear John,

did you follow the correct way to do it?

Anyway, place the following SAMPLE code at the very beginning of your main script.

Code: Select all

Load Feature Selections from file c:\test.state
Set Persistent Variable MYVAR to $MYVAR$
if Variable MYVAR Equals 
  MessageBox: Debug, Package not installed yet or never installed, so set persistent variable MYVAR.
  Set Variable MYVAR to $SFXPATH$
  Save Feature Selections into file c:\test.state
else
  MessageBox: Debug, Loaded  MYVAR value = $MYVAR$.
end
The same as clipboard format.

Code: Select all

~InstallAware Clipboard Data~
~End~
~{391C39DF-B428-45DF-8237-297ED16E5BE5}~
~MessageBox~
~{D9C19182-C641-46C2-AEEB-EDF9F353E79D}~
~Debug~
~Loaded  MYVAR value = $MYVAR$.~
~0~
~1~
~~
~Else~
~{006F5604-7A98-4DCA-BE72-F17A0DFAF96B}~
~Save Feature Selections~
~{64504B9C-FD0E-43C8-9605-F680364DD58B}~
~c:\test.state~
~Set Variable~
~{653A4CCD-26D4-4E05-8C9F-FF70D0077F7F}~
~MYVAR$MYAH$MYAH$FALSE~
~$SFXPATH$~
~MessageBox~
~{A65ECAF9-A95B-405B-BCD6-EAA41FCAE549}~
~Debug~
~Package not installed yet or never installed, so set persistent variable MYVAR.~
~0~
~1~
~~
~If~
~{07DF9E3E-3B2E-4192-9F89-300C6912CC14}~
~MYVAR~
~0~
~~
~FALSE~
~Set Variable~
~{2292EF7D-DD37-440F-B6CD-9CAD1A566EBF}~
~MYVAR$MYAH$MYAH$TRUE~
~$MYVAR$~
~Load Feature Selections~
~{4F74AED4-FB82-4B20-BE8C-5826F02D2CC2}~
~c:\test.state~
Hope this helps you.

Regards