You are here

Alteration of a *.txt file

5 posts / 0 new
Last post
tapsklaps
Offline
Last seen: 5 years 5 months ago
Developer
Joined: 2010-10-17 08:11
Alteration of a *.txt file

Suppose I have a *.txt file, in which I want to alter a value in a special line. This *.txt file may look as follows:

line 1: any entry
.
.
.
.
line n: [sectionname]
line n+1: value
.
.
.

Of course, the terms line 1, line 2, ... does not really appear in the *.txt, but only in the editor. My question is now, how can I change the value in line n+1? Has anyone an idea?

John T. Haller
John T. Haller's picture
Offline
Last seen: 5 hours 39 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Config

Can you paste the actual file? Or a snip of it? That may help. ConfigWrite can handle writing anything in the form of ENTRYNAMEVALUE as long as the ENTRYNAME is unique in beginnings of line in the whole file.

Sometimes, the impossible can become possible, if you're awesome!

tapsklaps
Offline
Last seen: 5 years 5 months ago
Developer
Joined: 2010-10-17 08:11
not applicable

Exactly this seems to be the problem, that this unique ENTRYNAME is missing. Accordingly "Configwrite" not seem to be applicable. It's the file "conf.txt", which is included in the app PeaZip. Here is the relevant snap:

themes\seven-embedded\theme.txt
themes\seven-embedded\
100
clWindow
clForm
clForm
$00669999
clWindowText
0


0
[language]
sv.txt
.
.
.

Especially I'm interested on the two lines, which are marked strong.

John T. Haller
John T. Haller's picture
Offline
Last seen: 5 hours 39 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Ah Ok

One option in that case is doing a replace and storing the last value as we do with SumatraPDF Portable. So it would start with the platform's language and then switch with it. Unless the user changes it themselves in the app, in which case it would cease automatically changing unless it synced up again.

The other option is custom code and reading in the file until you get to [language] and an end line and then reading in until the next end line. Then doing a replace in the file from that value to the new one. That wouldn't need to worry about syncing. And there is code that does something similar in a custom non-PAL launcher somewhere. I can't recall where offhand, though.

Sometimes, the impossible can become possible, if you're awesome!

tapsklaps
Offline
Last seen: 5 years 5 months ago
Developer
Joined: 2010-10-17 08:11
Thoughts about some possible solutions

Meanwhile I've thought about some possible solutions.

  1. Solution # 1

    Firstly I have pasted in the folder DefaultData\settings the file conf.txt with the following content:

    themes\seven-embedded\theme.txt
    themes\seven-embedded\
    100
    clWindow
    clForm
    clForm
    $00669999
    clWindowText
    0
    
    
    0
    [language]
    THISSTRINGWILLBEREPLACEDBYLANGUAGE.txt
    .
    .
    .
    

    Then I have pasted in the file PeaZipPortable.ini the following lines of code:

    [FileWrite7]
    Type=Replace
    File=%PAL:DataDir%\settings\conf.txt
    Find=THISSTRINGWILLBEREPLACEDBYLANGUAGE
    Replace=%PAL:LanguageCustom%
    

    But this solution doesn't work. Alternatively I have pasted in the file PeaZipPortable.ini the following lines of code:

    [FileWrite7]
    Type=ConfigWrite
    File=%PAL:DataDir%\settings\conf.txt
    Entry=THISSTRINGWILLBEREPLACEDBYLANGUAGE
    Value=%PAL:LanguageCustom%
    

    But once again this solution doesn't work

  2. Solution # 2

    A few weeks ago I've released a solution to the language problem in PeaZip in another post. All seemed to work fine. But now I have detected the following problem. Suppose I have changed the language after the run of the app in the PA.com menu. Now I closed the app. If I now start the app and I want change the language in the default language of the PA.c menu, then that default language doesn't appears about the menu Options -> Localization. The reason for that problem is, that due to the code in the hook ${SegmentPrePrimary} now the default language appears as "default.txt" and not as "de-uml.txt" in my special case.

    But how can I solve this problem?

Log in or register to post comments