You are here

FilesWriteN?

19 posts / 0 new
Last post
alysher
Offline
Last seen: 7 years 2 weeks ago
Joined: 2010-10-28 13:47
FilesWriteN?

does any one have an example or know of an app that uses this function in the launcher.ini for PA.c Launcher 2.0

i only ask cause i am having a hard time understanding the manual and an example of how it is used would allow me to see how it is used.

thanks in advanced.

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 9 years 4 months ago
Joined: 2007-04-15 21:08
Almost all

Almost all of the new apps released in the last few months are using PAL and the majority of PAL apps will use [FileWriteN] sections, for drive letter replacement most commonly. What are you trying to do? [FileWriteN] can do several quite different things.

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

depp.jones
Offline
Last seen: 1 day 3 hours ago
DeveloperTranslator
Joined: 2010-06-05 17:19
It's best to specify your

It's best to specify your problem and what you have tried so far. The variety of possible solutions might be more confusing as they differ in quite some way.

alysher
Offline
Last seen: 7 years 2 weeks ago
Joined: 2010-10-28 13:47
change values in the config file

what i need to do is change some values in a config file so that they update every time the device is moved from one machine to the next. now i understand how the type, file, entry, value, replace, find work, but its the section header in the launcher.ini that i am confused about....specificly the N in [FileWriteN]

now i am not sure if i am replacing values in the config file or if just using ConfigWrite will work for the changes that need to be implemented. does ConfigWrite replace values that are already in a config file?

OpenPlatform
OpenPlatform's picture
Offline
Last seen: 11 years 3 months ago
Joined: 2011-02-20 18:26
For Multiple [FileWriteN]...

The N in the [FileWriteN] is changed as follows...[FileWrite1], [FileWrite2], etc. depending on the current number of [FileWriteN]. You could use either configwrite or replace depending on what needs to be written to the file. For example:

[FileWrite1]
Type=Replace
File=%PAL:DataDir%\Profile\file.cfg
Find=%PAL:LastDrive%
Replace=%PAL:Drive%

[FileWrite2]
Type=ConfigWrite
File=%PAL:AppDir%\Profile\file.cfg
Entry="     

I have not used ConfigWrite alot, but I believe that is the method of doing so. Correct me if I am wrong

alysher
Offline
Last seen: 7 years 2 weeks ago
Joined: 2010-10-28 13:47
AHHHH!!!! I SEE THE LIGHT!

this wasn't explained in the PAL manual... knowing that i need a separate [FileWrite#] for each entry i intend to change in the config file makes sense.

you know, having a base example for the entire launcher.ini (like what openplatform posted) as part of the manual would be a MAJOR help in some situations.

depp.jones
Offline
Last seen: 1 day 3 hours ago
DeveloperTranslator
Joined: 2010-06-05 17:19
Ok, that problem was not to

Ok, that problem was not to be forseen, Wink
But did you see this part of the manual? The first example (scribus) shows how FileWriteN (e.g. FileWrite1, FileWrite2 ...) works.

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

It's worth mentioning that that part of the manual ("apps using PAL") doesn't exist in the 2.0 documentation (as only one (or was it two?) apps had been released officially with it, being the first release), only the 2.1 Beta documentation.

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

depp.jones
Offline
Last seen: 1 day 3 hours ago
DeveloperTranslator
Joined: 2010-06-05 17:19
Ok, wasn't aware of that

Ok, wasn't aware of that since I only use the beta.
But I crosschecked and the example is there, too, just at another position (examples on the first page). Your manual was really good, then, though the 2.1 version even better. Wink

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 9 years 4 months ago
Joined: 2007-04-15 21:08
Killing that bit

I'll be killing that bit off at some point, actually. It's somewhat out of date and I think that the list of examples will tend to be more helpful.

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

alysher
Offline
Last seen: 7 years 2 weeks ago
Joined: 2010-10-28 13:47
what about this.....

in my launcher.ini i am using both FileMove and FileWrite. now my files are not being written to nether before nor after the filemove. any one know why?

here is an example of my launcher.ini...

[FilesMove]
settings\config.cfg=%PAL:AppDir%\app

[FileWrite1]
Type=ConfigWrite
File=%PAL:AppDir%\app\config.cfg
Entry=ROMPath=
Value="%PAL:DataDir%\roms"

[FileWrite2]
Type=ConfigWrite
File=%PAL:AppDir%\app\config.cfg
Entry=SRAMPath=
Value="%PAL:DataDir%\SRAM"

[Don't use <pre><code>, just <pre> - mod Chris]

computerfreaker
computerfreaker's picture
Offline
Last seen: 13 years 1 month ago
Developer
Joined: 2009-08-11 11:24
Yep, simple mistake

FileWrite happens before the files get moved, so PAL is trying to write to %PAL:AppDir%\app\config.cfg after that file has been moved to %PAL:DataDir%\settings. Try changing
File=%PAL:AppDir%\app\config.cfg
to
File=%PAL:DataDir%\settings\config.cfg
in your FileWrite sections and that should work.

[Corrected "after" to "before" - mod Chris]

"The question I would like to know, is the Ultimate Question of Life, the Universe and Everything. All we know about it is that the Answer is Forty-two, which is a little aggravating."

alysher
Offline
Last seen: 7 years 2 weeks ago
Joined: 2010-10-28 13:47
and then there was more....

i just realized that my config file needs to have double backslashes in the paths. since the information isnt in the online manual for PAL how do i use %VARIABLE:DoubleBackslash% in my launcher.ini?

Aluísio A. S. G.
Offline
Last seen: 8 years 3 months ago
DeveloperTranslator
Joined: 2010-11-09 17:43
%PAL:DataDir:DoubleBackslash%
Value="%PAL:DataDir:DoubleBackslash%\\roms"
Value="%PAL:DataDir:DoubleBackslash%\\SRAM"

Previously known as kAlug.

alysher
Offline
Last seen: 7 years 2 weeks ago
Joined: 2010-10-28 13:47
Issues...

ok, i have some sort of problem or miscommunication on filewrite.

according to my previous posts i have everything correct, but when the launcher writes the file i end up with empty entries where i am suppose to have proper paths....for example:

ROMPath=""

instead of:

ROMPath="h:\\portableapps\\appnameportable\\data\\roms\\"

and yes i need to have the quotes on this line.

any one know what i am missing?

here is a sample of my code:

[FilesMove]
settings\config.cfg=%PAL:AppDir%\App

[FileWrite1]
File=%PAL:DataDir%\settings\config.cfg
Entry=ROMPath
Value="%PAL:DataDir:DoubleBackslash%\\roms\\"

*EDIT*

NeverMind....figured it out for my self.

it seems that filewrite was writing:

ROMPathh:\\portableapps\\appnameportable\\data\\roms

to the file. it turns out that i need to add the = to the entry and to double quote my value to get it to write properly....

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 9 years 4 months ago
Joined: 2007-04-15 21:08
ConfigWrite vs. INI

You need to understand the differences between the ConfigWrite and INI types. ConfigWrite purely does string matching and appending. This makes it suitable for anything. Say for example in Apache config files you get lines like "DocumentRoot X:\path" - that would be something like Entry="DocumentRoot ", Value=%PAL:Drive%\path. If you have an INI file with sections and keys, which is more common than an INI-style file without headings. Check the [FileWriteN] Type INI.

When you have matching quotes at the start and end of an INI string, they are interpreted specially (otherwise there would be no way to get leading or trailing whitespace). Be careful of this. Value="..." will not write quotes to the string. Use Value='"..."' if you want to write quotes.

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

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 9 years 4 months ago
Joined: 2007-04-15 21:08
Avoid quotes

In general I would recommend avoiding quotes which will be cut out by the INI parser; it can make it slightly confusing. Only include them when you need literal quotes - and then do it as Key='"Value"' (""Value"" would work just as well, but '""' is neater).

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

alysher
Offline
Last seen: 7 years 2 weeks ago
Joined: 2010-10-28 13:47
so i can use singles?

From what i am understanding from your previous posts it is my understanding that i can use single quotes (') to encapsulate my statement that needs double quotes around it instead of double quotes (") in my Value= statement. Correct?

i ask cause i think i had tried this before realizing that i needed to add my equals sign to my Entry= statement, but i honestly didnt think that using a single quotes would allow it to work.

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

I provide some information on it in the latest version of the manual - INI files; Keys.

After the equals sign, everything is just taken literally with whitespace trimmed and then a common start and end quote removed if they exist, so you can include other equals signs with no problems. So a ConfigWrite with Entry=KeyName= will work fine. (And it will be just the same as Entry="KeyName=", but there is no benefit in having the quotes and standard INI convention does not include quotes unless made necessary by leading or trailing whitespace or common quotes.

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

Log in or register to post comments