Archive: Decimal Delimiter


Decimal Delimiter
When installer shows space required/space availabe it use "." as decimal delimiter. For instance: "Space required 13.1Mb"
It shows "." regardless of system regional settings.

How can I make it use system's decimal delimiter rather then just "."?


Is it really that big of a deal?

anyways, there is already a bug report about it http://sourceforge.net/tracker/index...49&atid=373085


Our QA team reported it, therefore, I have to investigate.

Thanks! Hope it will be fixed sometimes soon.


You might be able to set the label text yourself, using SectionGetSize to get the size of a section, adding up for each selected section, and rounding that off to megabytes with decimals - with a comma for a decimal - yourself.. if it's something that can't wait for a fix in NSIS itself


Yes, I can change label text and can set whatver value I want. But I would be unable to change decimal delimiter in the number.


Edit: All's well - Here's what I have now...


SetCompress off
!include "MUI.nsh"
!include "WinMessages.nsh"
!include "LogicLib.nsh"

OutFile "c:\testsetup.exe"

Page Components ComponentsPre
!insertmacro MUI_LANGUAGE "English"

Var SpaceReq
SpaceTexts "Space Required: $SpaceReq$\r$\n$\r$\n$\r$\n"

Section "Test" Test
File "c:\windows\system32\wmploc.dll" ; 8,231,936bytes
SectionEnd

Function .onSelChange
; Initialize at zero bytes
StrCpy $0 0

; Add selected sections' sizes
${If} ${SectionIsSelected} ${Test}
SectionGetSize ${Test} $1
IntOp $0 $0 + $1
${EndIf}

InTop $0 $0 * 1024 ; KBytes -> Bytes

; Get MegaBytes
IntOp $1 $0 / 1000000
; Get MegaByte Fraction
IntOp $2 $0 % 1000000
; Only two characters, please (no rounding)
StrCpy $2 $2 2 0


; Same for MebiBytes (yeah, I hate the name, too)
IntOp $3 $0 / 1048576
IntOp $4 $0 % 1048576
StrCpy $4 $4 2 0

; Hey look, a comma and such
StrCpy $SpaceReq "$1,$2MB ($3,$4MiB)"
FunctionEnd

Function ComponentsPre
StrCpy $SpaceReq "Two Billion Bytes!" ; Initial size value
FunctionEnd


For any devs reading, SectionGetSize without the SectionSetSize returns 8039 - I've verified that the correct (7.8something MB) file is what is included in the installer.

That is the size in KB.


Originally posted by Joost Verburg
That is the size in KB.
A-ha. I was thrown off by the help's example for SectionGetSize:

Function .onInit
# increase required size of section 'test' by 100 bytes
SectionGetSize ${test_section_id} $0
IntOp $0 $0 + 100
SectionSetSize ${test_section_id} $0
FunctionEnd

Should read kbytes, then?

I'll adjust my post above - should be a simple mult by 1024 (presuming KiB and not KB)?
Edit: Yes - and done.

Keep in mind that using IntOp only works up to 2GB of required space. To be sure your code works for future projects, you might consider using the math plugin:

Math::Script'r1=ff(f($SPACENEEDED)/1048576,17);#***91;r1>999,r1=ff(r1/1024,17)+"GB",r1=r1+"MB"***93;'

I'm not sure if the math plugin uses the system's decimal sign, you might have to replace it in the output string manually.


Edit: Wait, I think I'm talking bullshit. Size in kilobytes, and all. >__<

The "required size" output on standard dialog constist of "LABEL" and "NUMBER":
"Required Space" "8.3MB"
Left part can be set as a string. OK.
Right part can be set only as a number. There are no way to change the format of the number. You cannot delete this number from the dialog and only left the label (wich can be edited as shown above).


er? have you tried the above code? That should replace the label and number; which should be the exact same control. Perhaps you're using a different UI, though? my example uses MUI


deleted


Thanks. Now I got it. Yes, it works.
However, we decided to defer this issue for now, and wait for NSIS team fix, as it require to many code for such a small issue (we also need to show space available... bla-bla-bla).


fair 'nuff :)