Code: Select all
procedure.s FormatByteSize(size.q)
define.s{32} res
StrFormatByteSize_(size, @res, 32)
procedurereturn res
endprocedure
debug FormatByteSize(1000)
Code: Select all
procedure.s FormatByteSize(size.q)
define.s{32} res
StrFormatByteSize_(size, @res, 32)
procedurereturn res
endprocedure
debug FormatByteSize(1000)

Code: Select all
Import "Shlwapi.lib"
CompilerSelect #PB_Compiler_Processor
CompilerCase #PB_Processor_x86
CompilerIf #PB_Compiler_Unicode
StrFormatByteSize64_(qdw.q, *pszBuf, cchBuf.l) As "_StrFormatByteSizeW"
CompilerElse
StrFormatByteSize64_(qdw.q, *pszBuf, cchBuf.l) As "_StrFormatByteSize64A"
CompilerEndIf
CompilerCase #PB_Processor_x64
CompilerIf #PB_Compiler_Unicode
StrFormatByteSize64_(qdw.q, *pszBuf, cchBuf.l) As "StrFormatByteSizeW"
CompilerElse
StrFormatByteSize64_(qdw.q, *pszBuf, cchBuf.l) As "StrFormatByteSize64A"
CompilerEndIf
CompilerEndSelect
EndImport
Procedure$ FormatByteSize(Size.q)
Protected Result$, Buffer${11}
If StrFormatByteSize64_(Size, @Buffer$, 11)
Result$ = Buffer$
EndIf
ProcedureReturn Result$
EndProcedure
Debug FormatByteSize(2047)