You are here

Laucher.ini, [FileWriteN] and a moving data directory

9 posts / 0 new
Last post
Ambimind
Offline
Last seen: 13 years 4 weeks ago
Joined: 2010-10-20 18:39
Laucher.ini, [FileWriteN] and a moving data directory

Hello everyone.

I've recently started working with the "PortableApps.com Launcher 2.0".

I have an issue I can't get around:

Briefly :

I need a way of accounting for a changing data directory location, that cannot be accounted for using environment variables(of windows or the launcher's internal vars). I could solve the problem if [FileWriteN] allowed for wild-cards(*,?) - or it was possible to define custom variables.

----
The launcher .ini file:

[Launch]
ProgramExecutable=InstantInvoiceCashBook\InstantInvoiceCashBook.exe

[FileWrite1]
Type=replace
File=%PAL:DataDir%\EzySoft\InstInvCashBk\Recent\Recent.IDX
Find=%PAL:LastDrive%\
Replace=%PAL:DataDir%\

[Environment]
APPDATA=%PAL:DataDir%

----
In Detail :

- The application(to be made portable) stores data in a user defined directory(eg. "Drive":\"somedir"\"somedir2"\progdata).

- The location of this directory is stored in an MRU in %APPDATA%.

- So that the data is always accessible to the program I set the data directory to be inside the "AppNamePortable" folder(Eg."Drive":\"AppNamePortable"\progdata) - this is set in the application.

- I make the appropriate launcher .ini changes and as long as the portable app directory is kept at, "Drive":\"AppNamePortable", everything works fine.

- However if this folder is placed in a sub-folder(eg. "Drive":\"somefolder"\"AppNamePortable") the user defined "progdata" can no longer be accounted for by [FileWriteN]. Simple drive letter substitution no longer works because there is an extra directory term between the drive letter and the portable app folder.

- I've tried without success:
Find=%PAL:LastDrive%\*\
Replace=%PAL:DataDir%\
(note: In this attempt I re-set the "progdata" directory to "%PAL:DataDir%\" which ought to account for any changes.)

---

Any help would be appreciated,

Ambimind

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 9 years 3 months ago
Joined: 2007-04-15 21:08
Possible and coming

In version 2.1 there are numerous improvements which will directly affect what you're doing. For starters, read the Support for directory moving section in the release notes for 2.1 to see what's coming - PAL:LastPackagePartialDir and PAL:PackagePartialDir will do precisely what you want. Be aware that it has been our policy of old to not bother supporting such moving around, so at the moment it's not a requirement to support that; however, we are shifting towards supporting it better and so supporting it yourself is a great thing to do.

Support for creating custom environment variables programatically is also possible if you ever need it; you can use ${SetEnvironmentVariable} variable value in custom code to set an environment variable, or ${SetEnvironmentVariablesPath} variable value to set variable, variable:ForwardSlash, etc.

If you want to get started with 2.1 before it's released, get it here, always the latest code fresh from the repository.

I am a Christian and a developer and moderator here.

“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1

Ambimind
Offline
Last seen: 13 years 4 weeks ago
Joined: 2010-10-20 18:39
Attempt at solution

Thanks for taking the time to read my long post. I now understand my predicament exactly, thanks.

Here is what I'm trying as a solution(the basic idea is to track "PAL:DataDir" like your currently doing with "Pal:Drive"):

1 - Create a file in my "AppNamePortable"\Other\Source\PortableApps.comLauncherCustom.nsh

2 - Hack together some of your code:
${SegmentFile}
Var LastDataLoc
Var CurrentDataLoc

${SegmentInit}
ReadINIStr $LastDataLoc $EXEDIR\Data\settings\$AppIDSettings.ini $AppIDSettings LastDataLoc
StrCpy $CurrentDataLoc $EXEDIR\Data
${IfThen} $LastDataLoc == "" ${|} StrCpy $LastDataLoc $CurrentDataLoc ${|}

${SetEnvironmentVariable} PAL:CurrentDataLoc $CurrentDataLoc
${SetEnvironmentVariable} PAL:LastDataLoc $LastDataLoc

WriteINIStr $DataDirectory\settings\$AppIDSettings.ini $AppIDSettings LastDataLoc $LastDataLoc
!macroend

3 - Expect to find a new key named LastDataLoc, in "$DataDirectory\settings\$AppIDSettings.ini", however no-matter how many times I run the app or recreate the launcher it doesn't appear?

I have a feeling I'm missing something fundamental?

Thanks,

Ambimind

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 9 years 3 months ago
Joined: 2007-04-15 21:08
PAL:PackagePartialDir

My advice is to go with the hg tip and then use %PAL:LastDrive%%PAL:LastPackagePartialDir%\Data and %PAL:Drive%%PAL:PackagePartialDir%\Data.

I am a Christian and a developer and moderator here.

“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1

Ambimind
Offline
Last seen: 13 years 4 weeks ago
Joined: 2010-10-20 18:39
I'm afraid I don't know what

I'm afraid I don't know what I should do with the package I downloaded, merge it with my current PAL launcher directory?

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 9 years 3 months ago
Joined: 2007-04-15 21:08
It /is/ that

What you download with that is the PortableApps.com Launcher package, minus the manual built (read the latest at http://portableapps.chrismorgan.info/launcher/manual) and PortableApps.comLauncherGenerator.exe built (so compile Other\Source\GeneratorWizard.nsi with NSIS Portable).

I am a Christian and a developer and moderator here.

“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1

Ambimind
Offline
Last seen: 13 years 4 weeks ago
Joined: 2010-10-20 18:39
Done, but beaten

Thanks, compile of PAL launcher 2.1 done, changed the .ini file with new vars - substitution works perfectly!

Unfortunately, it turns out, the MRU files are database files which do not tolerate any lengthening of table entries; doing so creates an inconsistency between the header section and the content of the file; which the software interprets as a corrupt database file -- the result is that the program doesn't work.

--

Putting that aside, I wanted to show my admiration for the work you've put into this project - having looked through the \source folder I can see the immense time and thought you've put into it - into making it easy to use while retaining maximum flexibility.THANK YOU!
I'll certainly be using it from now on.

Regards,

Ambimind

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 9 years 3 months ago
Joined: 2007-04-15 21:08
Thanks, good to hear you've

Thanks, good to hear you've got it working.

What format are the database files? If they're MDB something could potentially be done about it in custom code, if they're SQLite then something can definitely be done in custom code (refer to the Songbird launcher - it doesn't use PAL but the snippets for manipulating a SQLite database can easily be pulled in and I intend to do that for 2.2 or 2.3 or some release).

I am a Christian and a developer and moderator here.

“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1

Ambimind
Offline
Last seen: 13 years 4 weeks ago
Joined: 2010-10-20 18:39
The database component of the

The database component of the software comes from http://www.elevatesoft.com/ in the form of a Delphi6 component.

I'll definitely look into the sources you've mentioned for future projects, however since I have the software working(with some minor conditions placed on the user) and because I can't justify spending more time on it I'll leave it as is.

Thanks again,

Ambimind

Log in or register to post comments