Search code examples
nsis

NSIS ${LineRead} dont give the correct information


For an installer i need a specific delete function. In case i have a txt-file where i have all Folders where i need to delete.

The txt File is Build up in this way:

addon1Success
addon2Success
addon3Failed

I have around 10 of this lines.

The main Problem is that when i print out the Information where i get from the ${LineRead} - Function is not the Line like above its a number like in my test case 30.
Maybe i have a mistake in my code:

 !include "${NSISDIR}\Include\LogicLib.nsh"
 !include "myLogger.nsh" ;
 Var i

 Function removeFolder
 IntOp $i $i * 0
  ${ForEach} $i 0 $lineCount + 1
    ${LineRead} "$TEMP\addonInstallerPreFolder\addons\postponeLog.txt" "$i - $i" $0
    !insertmacro LOGGER_WRITE "DEBUG Text $0" "0"

    ${StrContains} $0 "Success" $1
    ${if} $1 == "Success"
        Push "Success"
    ${else}
        Push "Failed"
    ${endif}
    Push $0
    Call Slice
    Pop $R0

    ${if} $revertAfter == "true"
        CopyFiles "$INSTDIR\addons\backup_$R0\*" "$INSTDIR\addons\$R0"
        !insertmacro LOGGER_WRITE "Revert Backupfolder to AddonFolder $R0" "0"
    ${endif}
    !insertmacro LOGGER_WRITE "Removed Backup folder of $R0" "0"
    Delete "$INSTDIR\addons\backup_$R0"
${next}
FunctionEnd

i hope you can help to finde the resolve that i get only a digit and not a text


Solution

  • @Cris Looking at your code

    ${LineRead} "$TEMP\addonInstallerPreFolder\addons\postponeLog.txt" "$i - $i" $0
    

    First: The third variable "[LineNumber]" should be a single digit. It looks like you have the variable $i - $i. I believe you just need "$i".

    Second: The fourth variable in the documentation LineRead function shows using $R0. It looks like you are using $0 for the function, and using $0 in some areas of your code, but using $R0 in other areas.