Archive: Creating Text Files


Creating Text Files
  Bravo to the Nullsoft team for another fantastic product.

NSIS and Winamp are two of the most useful apps I have installed for a long time.

Are there any plans a-foot to add support for creating text files from an NSIS script?

Currently I have worked around this by using:
ExecWait "command.com /c cat $TEMP\top.txt >> MyFile.txt"
ExecWait "command.com /c echo set INSTALLEDINTO $INSTDIR>> MyFile.txt"
ExecWait "command.com /c cat $TEMP\bottom.txt >> MyFile.txt"

This works but isn't very elegant :(

I am using NSIS to install Java Apps and I wanted to be able to generate a .properties file based on some of the installer details.

Thanks for the great product in any case tho!!!


It would be pretty trivial to make a win32 GUI exe that does what you need.. i.e.


int main(int argc, char **argv)
{
FILE *fp=fopen(argv[1],"a+");
fprintf(fp,"%s\n",argv[2]);
fclose(fp);
}


Of course you'd have to make it win32ized, so that a) it wouldn't be a console mode app, b) it would be smaller.

Then you'd call this executable like this:


SetOutPath $TEMP
Extract concat.exe
ExecWait '$TEMP\concat.exe "$INSTDIR\whatever.dat" "string to append!"'
ExecWait '$TEMP\concat.exe "$INSTDIR\whatever.dat" "string to append2!"'
Delete $TEMP\concat.exe


If you really really want, I'll make a win32 version, but bleh =)

-Justin

Kewl

Done thanks to my years gone by with Delphi

I take it that this feature probly wont sneak into NSIS then :)


Actually I'm kinda thinking of adding functions like FileOpen, FileRead, FileWrite, FileSeek, FileTell, and FileClose.

So you could do things like


FileOpen $1 "$TEMP\more.txt" READ

FileOpen$0 "$INSTDIR\hi.txt" WRITE
FileRead$1 $2
FileWrite$0 "Test: $2$\r$\n"
>FileClose $0
FileClose$1
>
or something like that. Thinking it would add around 512-1024 bytes to the EXE header, but would be very powerful.

-Justin

kick ass
  that would be bad ass justin... the uses are boundless... any chance we are going to be able to switch to PHP based scripts? from my view it looks like thats where we are going ;)


Hell Yeah!!!!!!!!! Then my months of learning PHP are not made to waist!

-Duane


re; PHP.. the zend engine is open source and can be made to work with other programs. Would have to do a bit of hacking to get it all working.. e.g. the instructions would need to be stored rather than executed, so perhaps a makensis that used the prescanned Zend code.


I was kinda hoping my question may prompt some direct supportin NSIS :D

Fantastic stuff, Cheers Justin!

Eejut


I see some new features in v1.6 beta

wicked :D