Generate a random number: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Adding new author and category links.) |
m (Added link to User:Afrow UK.) |
||
Line 34: | Line 34: | ||
</highlight-nsis> | </highlight-nsis> | ||
== Example == | |||
[[User:Afrow UK|Afrow UK]] used this to generate random BrandingImages for placing on the side of my installer during the installation process. | |||
You can use the value generated like so: | You can use the value generated like so: |
Revision as of 11:42, 30 September 2005
Author: Afrow UK (talk, contrib) |
Description
This is a simple script to generate a number between 0 and 9.
Usage
Call GenRanNum Pop $R0
The Function
Function GenRanNum Push $R0 Push $R1 Push $R2 GetTempFileName $R0 GetFileTime $R0 $R1 $R2 StrLen $R1 $R2 StrCpy $R1 $R2 1 -$R1 StrCmp $R1 - 0 +5 StrLen $R1 $R2 IntOp $R1 $R1 - 1 StrCpy $R2 $R2 1 -$R1 Goto +2 StrCpy $R2 $R1 Delete $R0 StrCpy $R0 $R2 Pop $R2 Pop $R1 Exch $R0 FunctionEnd
Example
Afrow UK used this to generate random BrandingImages for placing on the side of my installer during the installation process.
You can use the value generated like so:
IntCmp $R2 2 0 0 +3 SetBrandingImage "$TEMP\ddayupdates\left_logo1.bmp" Goto set_bitmap_end IntCmp $R2 5 0 0 +3 SetBrandingImage "$TEMP\ddayupdates\left_logo2.bmp" Goto set_bitmap_end IntCmp $R2 7 0 0 +3 SetBrandingImage "$TEMP\ddayupdates\left_logo3.bmp" Goto set_bitmap_end SetBrandingImage "$TEMP\ddayupdates\left_logo4.bmp" set_bitmap_end:
-Stu