Archive: random


random
  Is possible to have a * as 6 random numbers in something like this


Function .onInit
StrCpy $0 0
loop:
IntOp $0 $0 + 1

ReadIniStr $1 "$EXEDIR\file.ini" "Base" "HF$0"
StrCmp $1 "" ExitLoop

MessageBox MB_OK "line $0 = $1"

Goto loop

Exitloop:
FunctionEnd

I mean have "HF*" and see all lines that start with HF and have 6 random numbers after it like HF296193, HF864284 and so on. I have searched the forum and didn't find this mentioned. Is this possible? :rolleyes:

Not that I know of; but, I do know a way around it. The following hasn't been tested, though it should work. I use the same concept in my installers.

INI:


***93;

>Objects=6
HF1
=A
HF2=B
HF3=C
HF4=D
HF5=E
HF6=F
>
Code:

"MAX_COUNTER"

>Var "CURRENT_COUNTER"
>Var "ARRAY"
>Var "SEPERATOR"
>Function .onInit
StrCpy CURRENT_COUNTER "0"
ReadIniStr $MAX_COUNTER "$EXEDIR\file.ini" "Base" "Objects"
IntCmp $MAX_COUNTER 0 ExitLoop
StrCpy $ARRAY ""
StrCpy $SEPERATOR ";"

>loop:
IntCmp $CURRENT_COUNTER $MAX_COUNTER 0 0 Exitloop

ReadIniStr$1 "$EXEDIR\file.ini" "Base" "HF$CURRENT_COUNTER"
StrCpy $ARRAY "$1$SEPERATOR"

>IntOp $CURRENT_COUNTER $CURRENT_COUNTER + 1

Goto loop

Exitloop:

>MessageBox mb_ok "$ARRAY"
>; Parse the array to obtain your values.
>FunctionEnd
>

Hi. I belive $EXEDIRfile.ini should be $EXEDIR\file.ini and StrCpy CURRENT_COUNTER "0" should be StrCpy $CURRENT_COUNTER "0" nut I still can't get it to work..

the file.ini looks like:
[Base]
HF235967="moo"
HF646858="foo"
HF987465="bla"

if it's possible I would like to have separate "HF235967" and "moo" from each line in an variable or something..