ssam
3rd June 2008 10:28 UTC
file not completly written
ac.jnlp is my configfile with 53 lines, i read a tamplat of them, replace some placeholder and writ them to a specific directory.
Var /global ac.jnlp_template
Var /global fp_ac.jnlp
ClearErrors
FileOpen $fp_ac.jnlp '${copiedfiles_Path}\Templates\html\diag\\jnlp\ac\ac.jnlp' r
IfErrors ac.jnlp_done
FileRead $fp_ac.jnlp $2
Detailprint $2
IfErrors ac.jnlp_eof
StrCpy $ac.jnlp_template '$ac.jnlp_template$2'
Goto -4
ac.jnlp_eof:
FileClose $fp_ac.jnlp
Var /global fp_ac.jnlp_patched
Var /global ac.jnlp_patched
${StrRep} $ac.jnlp_patched "$ac.jnlp_template" "$Server" "$Servername" #Ersetzen des Platzhalters $Server mit dem Inhalt der Variablen $Server
SetOutPath '$INSTDIR\html\diag\jnlp\AC'
ClearErrors
FileOpen $fp_ac.jnlp_patched 'ac.jnlp' w
IfErrors ac.jnlp_patched_done
FileWrite $fp_ac.jnlp_patched $ac.jnlp_patched
Messagebox MB_OK "$ac.jnlp_patched"
FileClose $fp_ac.jnlp_patched
Goto +4
ac.jnlp_patched_done:
DetailPrint 'Konnte ac.cfg nicht öffnen.(schreiben)'
Goto +2
ac.jnlp_done:
DetailPrint 'Konnte ac.cfg nicht öffnen.(lesen)'
ok the detailprint show me, that my file is completely read.
but if i write the string to the file, he only writes 29 lines. This is a Problem.
ssam
3rd June 2008 10:53 UTC
in a second test he writes only 31 lines with fewer text per line. in my opinion is the space of a Variable to small.
ssam
3rd June 2008 11:00 UTC
or the length of the string is too small
{_trueparuex^}
3rd June 2008 11:03 UTC
NSIS variables are limited to 1024 characters. You can download NSIS special build with 8192 max string length, but that isn't really a solution.
What you should do is to read and write the file in 1024 blocks. It needs a little planning, but it can be done.
PaR
ssam
3rd June 2008 11:12 UTC
oh thats a good info, thanks.
ssam
3rd June 2008 11:59 UTC
ok i chaned it but now i have an "ungültiger Befehlscode"-Error
Var /global fp_alarmconfigurator.cfg
Var /global fp_alarmconfigurator.cfg_patched
Var /global alarmconfigurator.cfg_template
Var /global alarmconfigurator.cfg_patched
/* Datei einlesen und schreiben*/
ClearErrors
FileOpen $fp_alarmconfigurator.cfg '${copiedfiles_Path}\Templates\html\diag\jnlp\AlarmConfigurator\alarmconfigurator.cfg' r
IfErrors alarmconfigurator.cfg_done
Messagebox MB_OK "öffnen lesen ging"
ClearErrors
SetOutPath '$INSTDIR\html\diag\jnlp\AlarmConfigurator'
FileOpen $fp_alarmconfigurator.cfg_patched 'alarmconfigurator.cfg' w
IfErrors alarmconfigurator.cfg_patched_done
Messagebox MB_OK "öffnen schreiben ging"
ClearErrors
Messagebox MB_OK "vor dem zeile lesen"
FileRead $fp_alarmconfigurator.cfg $1
Messagebox MB_OK "zeilen lesen ging \r\n Wert: $1"
IfErrors alarmconfigurator.cfg_eof
StrCpy $alarmconfigurator.cfg_template '$1'
${StrRep} $alarmconfigurator.cfg_patched "$alarmconfigurator.cfg_template" "$ServerDB" "$ProduktivDB_Hostname"
#${StrRep} $alarmconfigurator.cfg_patched "$alarmconfigurator.cfg_patched" "" "$ProduktivDB_TNSname"
${StrRep} $alarmconfigurator.cfg_patched "$alarmconfigurator.cfg_patched" "$DB" "$ProduktivDB_DBSID"
#${StrRep} $alarmconfigurator.cfg_patched "$alarmconfigurator.cfg_patched" "" "$ProduktivDB_Listenerport"
${StrRep} $alarmconfigurator.cfg_patched "$alarmconfigurator.cfg_patched" "$User" "$ProduktivDB_Mainuser"
#${StrRep} $alarmconfigurator.cfg_patched "$alarmconfigurator.cfg_patched" "" "$ProduktivDB_MainuserPasswort"
${StrRep} $alarmconfigurator.cfg_patched "$alarmconfigurator.cfg_patched" "$Server" "$Servername"
FileWrite $fp_alarmconfigurator.cfg_patched $alarmconfigurator.cfg_patched
iferrors 0 +2
Messagebox MB_OK "Fehler beim schreiben"
Messagebox MB_OK "zeile schreiben ging \r\n Wert: $alarmconfigurator.cfg_patched"
Goto -13
alarmconfigurator.cfg_eof:
FileClose $fp_alarmconfigurator.cfg_patched
FileClose $fp_alarmconfigurator.cfg
Goto +4
alarmconfigurator.cfg_patched_done:
DetailPrint 'Konnte alarmconfigurator.cfg_template nicht öffnen.(schreiben)'
Goto +2
alarmconfigurator.cfg_done:
DetailPrint 'Konnte alarmconfigurator.cfg_template nicht öffnen.(lesen)'
the first line is writen into the File, but then where he must jump 13 Lines back, there comes the Error
I dont know why
{_trueparuex^}
3rd June 2008 12:05 UTC
Use jump to label instead of relative jump. ${StrRep} is a macro so there is actually a lot more lines than 13.
PaR
ssam
3rd June 2008 12:10 UTC
oh ... ok
ssam
3rd June 2008 12:44 UTC
thanks this helps