Archive: Displaying a read me file in a custom page


Displaying a read me file in a custom page
  Hi,

I'd like to read in the readme.txt file and display it in a custom page. I'm having a problem reading the file in and storing it in a variable that I can use as the content of a dialog. The following code has problems, it reads all 128 lines of the code but apparently there is a limit on how much strcpy will copy because at the end I only have the first 963 characters of the read me file in the string.

         FileOpen$0 "$INSTDIR/readme.txt" r

StrCpy$3 "" ; initialize!
loop:
FileRead $0 $2
IfErrors done
StrCpy$3 "$3$2"
Goto loop
done:
FileClose $0
LogText "Setting ready message\r\n$3"
Is there a better way to do this? Is there a way to append text to the control?
Thanks.

The NSIS variables can hold up to 1024 char by default. I would just preper an INI file ahead instead of doing it in the script.


So, you're suggesting stuffing my readme.txt file in an INI file and using a custom dialog to display it? This would add complexity to the automated build process, the INI file would have to be generated before the project was compiled so any changes to the read me would be picked up, and since the readme would have to be available in at least two languages to support multiple locales, it wouldn't possible to use LangStrings since they probably only can contain 1024 characters anyway.

If I were to go on this route, how would I specify a license like control in an INI file? Labels don't have scroll bars and aren't bileveled. Text boxes are editable by the user and it doesn't appear that I can set their default value through the INI file.

Any suggestions would be appreciated.


Stuffing the readme in the INI file is exactly what you were trying to do with the script above.

You can always use !system to do what ever you want on script compile time.

LangStrings can hold as many chars as you would like.

In the latest CVS version you can specify the disable flag to IO controls so the text control won't be editable. But it won't have scroll bars anyway.

I would go for two NSIS license page with SendMessage WM_SETTEXT in the second. Much more simpler than custom pages. Then you can use RTFs too. That, of course, will work only if you still want the same license data in the two pages.


To clarify, I was reading the file in and then doing a SendMessage call to update the value of the license control.

So, what you're saying is what I want to do can't currently be done? I read in an earlier post that 2.0b would have the ability to show different licences on different pages, this would solve my problem, I could just put the readme file in a license dialog. Do you know when this feature will be available?


Yep that will be availble, in the future... When I get to it :D

In another post you said you want to show the same license data twice. If that's not the case you can (another idea) write the readme into the ini file in chunks instead of getting it prepered. But there still isn't any control with a scroll bar...

So, do you want to show the same license data or not?


Hi,

That was a separate issue. In Japan there is a different license acceptance workflow, the user must first read and click that they understand the license and then read and click that they accept the license.

What I'm trying to accomplish now is make sure the user has the ability to read the readme file before they launch the installed application.

I think I might go ahead and see if I can't modify the InstallOptions dll to provide a control that I can use for this purpose. I'll post it here if I can do it.


OK. So if it's the same license data why don't you want to use Page license twice and use SendMessage WM_SETTEXT to just change the button and the text above the license data?


Like I said, there are two different/separate things I want to do.

#1 Two step license agreement, show the license twice, first time for the user to click they understand it, second time for acceptance, which was accomplished with what you just specified.

#2 Display the readme.txt file in a dialog after setup has copied the files and before the user can run the application by launching it at the end of the setup process.


OK, I am sorry for the confusion.

#1 you can do with two Page license and SendMessage WM_SETTEXT on the second/first (however you choose to set the default).

#2 will have to be done either with an IO page or just ExecWait notepad.exe. ExecWait will be the easiet solution unless you must have it in the NSIS dialog.


bringing this up from the dead ;)
  How would one go about using an IO page to do this (make another page identical to the license page except with different data)? I'm not l33t enough to figure things out for myself. Or, is there an easier way to do this now that NSIS 2.0b3 is out?


pkp wrote this plugin: http://nsis.sourceforge.net/archive/...php?pageid=228. It uses MFC so it's not really useful for an installer, and it has some other strange code.

If you can write C/C++, you might want to write a better plugin. A good example of a custom page plugin is StartMenu, so you can get a lot of code from that one.


IO stands for InstallOptions, which is a plug-in that creates customized pages according to an INI file. There are example for it in Examples\Modern UI\InstallOptions.nsi and Contrib\InstallOptions\test.nsi. This thread explains another possible method.