devdas_kamath
19th January 2008 04:07 UTC
number checking
Dear sir,
how to compare 2 numbers and fetch result which is greater. a=89.1 and b=78.2. first i want to compare 89 and 78 and get the result and then compare 1 and 2 and get the result. for comparision i can use IntCmpU and determine which is greater, equal or less. but my problem is how to read 89 and 78 from variable a(89.1) and b(78.2) and then 1(89.1) and 2(78.2). pls let me know how to do that. thanks in advance.
regards
devdas m. kamath:weird:
Red Wine
19th January 2008 11:16 UTC
!define _A_ '89.1'
!define _B_ '78.2'
!define _C_ '199.4478'
!define _SYMBOL_ '.'
outfile test.exe
showinstdetails show
Section -
StrCpy $R0 '${_A_}'
call MyFunc
messagebox mb_ok '$R1 -- $R2'
StrCpy $R0 '${_B_}'
call MyFunc
messagebox mb_ok '$R1 -- $R2'
StrCpy $R0 '${_C_}'
call MyFunc
messagebox mb_ok '$R1 -- $R2'
SectionEnd
Function MyFunc
StrCpy $0 ''
StrCpy $1 0
_loop:
StrCpy $2 $R0 1 $1
StrCmp $2 '${_SYMBOL_}' +1 +3
StrCpy $R1 '$0'
StrCpy $0 ''
StrCmp $2 '${_SYMBOL_}' +2
StrCpy $0 '$0$2'
StrCmp $2 '' +1 +3
StrCpy $R2 '$0'
Goto _end
IntOp $1 $1 + 1
Goto _loop
_end:
FunctionEnd
freeDB_man
25th January 2008 16:42 UTC
i used this and it worked fine but if i want to search for something like ".0" it doesnt work and i tried changing it to IntOp $1 $1 + 1 but it still wont work
any sugesstions???
Red Wine
25th January 2008 16:59 UTC
This is working specifically for the requested operation by devdas_kamath.
What exactly you're trying to do?
freeDB_man
25th January 2008 17:58 UTC
i will check if a no has a number 0f zeros after the point and manipulate it as the string becomes quite large after some time so i might be able to strip it down
Red Wine
25th January 2008 18:16 UTC
!define INPUT `1.20.300.0900`
!define STR2SEARCH '.0'
!include LogicLib.nsh
outfile test.exe
showinstdetails show
Section -
StrCpy $R0 '${INPUT}'
call MyFunc
DetailPrint '$R1'
SectionEnd
Function MyFunc
StrCpy $1 0
${Do}
StrCpy $2 $R0 2 $1
IntOp $1 $1 + 1
${Select} $2
${Case} ${STR2SEARCH}
StrCpy $R1 $2
${ExitDo}
${Case} ''
StrCpy $R1 'not found'
${ExitDo}
${CaseElse}
${EndSelect}
${Loop}
FunctionEnd