Statistiques
| Révision :

root / tmp / org.txm.setups / nsis-2.5 / Examples / primes.nsi @ 3079

Historique | Voir | Annoter | Télécharger (1,62 ko)

1 2961 mdecorde
; primes.nsi
2 2961 mdecorde
;
3 2961 mdecorde
; This is an example of the possibities of the NSIS Script language.
4 2961 mdecorde
; It calculates prime numbers.
5 2961 mdecorde
6 2961 mdecorde
;--------------------------------
7 2961 mdecorde
8 2961 mdecorde
Name "primes"
9 2961 mdecorde
AllowRootDirInstall true
10 2961 mdecorde
OutFile "primes.exe"
11 2961 mdecorde
Caption "Prime number generator"
12 2961 mdecorde
ShowInstDetails show
13 2961 mdecorde
AllowRootDirInstall true
14 2961 mdecorde
InstallDir "$EXEDIR"
15 2961 mdecorde
RequestExecutionLevel user
16 2961 mdecorde
17 2961 mdecorde
DirText "Select a directory to write primes.txt. $_CLICK"
18 2961 mdecorde
19 2961 mdecorde
;--------------------------------
20 2961 mdecorde
21 2961 mdecorde
;Pages
22 2961 mdecorde
23 2961 mdecorde
Page directory
24 2961 mdecorde
Page instfiles
25 2961 mdecorde
26 2961 mdecorde
;--------------------------------
27 2961 mdecorde
28 2961 mdecorde
Section ""
29 2961 mdecorde
  SetOutPath $INSTDIR
30 2961 mdecorde
  Call DoPrimes
31 2961 mdecorde
SectionEnd
32 2961 mdecorde
33 2961 mdecorde
;--------------------------------
34 2961 mdecorde
35 2961 mdecorde
Function DoPrimes
36 2961 mdecorde
37 2961 mdecorde
; we put this in here so it doesn't update the progress bar (faster)
38 2961 mdecorde
39 2961 mdecorde
!define PPOS $0 ; position in prime searching
40 2961 mdecorde
!define PDIV $1 ; divisor
41 2961 mdecorde
!define PMOD $2 ; the result of the modulus
42 2961 mdecorde
!define PCNT $3 ; count of how many we've printed
43 2961 mdecorde
  FileOpen $9 $INSTDIR\primes.txt w
44 2961 mdecorde
45 2961 mdecorde
  DetailPrint "2 is prime!"
46 2961 mdecorde
  FileWrite $9 "2 is prime!$\r$\n"
47 2961 mdecorde
  DetailPrint "3 is prime!"
48 2961 mdecorde
  FileWrite $9 "3 is prime!$\r$\n"
49 2961 mdecorde
  Strcpy ${PPOS} 3
50 2961 mdecorde
  Strcpy ${PCNT} 2
51 2961 mdecorde
outerloop:
52 2961 mdecorde
   StrCpy ${PDIV} 3
53 2961 mdecorde
   innerloop:
54 2961 mdecorde
     IntOp ${PMOD} ${PPOS} % ${PDIV}
55 2961 mdecorde
     IntCmp ${PMOD} 0 notprime
56 2961 mdecorde
     IntOp ${PDIV} ${PDIV} + 2
57 2961 mdecorde
     IntCmp ${PDIV} ${PPOS} 0 innerloop 0
58 2961 mdecorde
       DetailPrint "${PPOS} is prime!"
59 2961 mdecorde
       FileWrite $9 "${PPOS} is prime!$\r$\n"
60 2961 mdecorde
       IntOp ${PCNT} ${PCNT} + 1
61 2961 mdecorde
       IntCmp ${PCNT} 100 0 innerloop
62 2961 mdecorde
       StrCpy ${PCNT} 0
63 2961 mdecorde
       MessageBox MB_YESNO "Process more?" IDNO stop
64 2961 mdecorde
     notprime:
65 2961 mdecorde
       IntOp ${PPOS} ${PPOS} + 2
66 2961 mdecorde
     Goto outerloop
67 2961 mdecorde
   stop:
68 2961 mdecorde
  FileClose $9
69 2961 mdecorde
70 2961 mdecorde
FunctionEnd