Search found 16 matches: swprintf
Searched query: +swprintf
- Thu Oct 06, 2022 9:03 pm
- Forum: Coding Questions
- Topic: Justification of data in strings
- Replies: 11
- Views: 1410
- Wed Mar 24, 2021 10:58 pm
- Forum: Coding Questions
- Topic: DateDiff question
- Replies: 7
- Views: 8892
Re: DateDiff question
For this to work on Linux, you need to replace the swprintf function
Format.pb
XIncludeFile "Format.pb"
...
Protected Buff.s
Buff = Format( "%i.%02i.%02i %02i:%02i:%02i", @R(0), @R(1), @R(2), @R(3), @R(4), @R(5))
another option:
ImportC ""
sprintf(*str, format.p-utf8, Param1=0, Param2=0 ...
Format.pb
XIncludeFile "Format.pb"
...
Protected Buff.s
Buff = Format( "%i.%02i.%02i %02i:%02i:%02i", @R(0), @R(1), @R(2), @R(3), @R(4), @R(5))
another option:
ImportC ""
sprintf(*str, format.p-utf8, Param1=0, Param2=0 ...
- Wed Mar 24, 2021 11:28 am
- Forum: Coding Questions
- Topic: DateDiff question
- Replies: 7
- Views: 8892
Re: DateDiff question
ImportC "msvcrt.lib"
swprintf(*s, Format.s, Param1=0, Param2=0, Param3=0, Param4=0, Param5=0, Param6=0)
EndImport
Error_Procedure = 0
; AutoIt3 UDF
Procedure _DateIsLeapYear(Year)
If Mod(Year, 4) = 0 And Mod(Year, 100) <> 0
ProcedureReturn 1
ElseIf Mod(Year, 400) = 0
ProcedureReturn 1
Else ...
swprintf(*s, Format.s, Param1=0, Param2=0, Param3=0, Param4=0, Param5=0, Param6=0)
EndImport
Error_Procedure = 0
; AutoIt3 UDF
Procedure _DateIsLeapYear(Year)
If Mod(Year, 4) = 0 And Mod(Year, 100) <> 0
ProcedureReturn 1
ElseIf Mod(Year, 400) = 0
ProcedureReturn 1
Else ...
- Thu Jul 19, 2018 3:08 pm
- Forum: Tricks 'n' Tips
- Topic: Format string with some values like sprintf (C)
- Replies: 62
- Views: 39757
Re: Format string with some values like sprintf (C) - Update
... From what I've read online when it comes to C, float arguments to variadic function are promoted to double. So for a function like sprintf / swprintf, you always need to use a double when importing the function or using PrototypeC.
After that, passing a float (.f) works fine as PB will convert ...
After that, passing a float (.f) works fine as PB will convert ...
- Thu Jul 19, 2018 2:59 pm
- Forum: Tricks 'n' Tips
- Topic: Format string with some values like sprintf (C)
- Replies: 62
- Views: 39757
Re: Format string with some values like sprintf (C) - Update
... From what I've read online when it comes to C, float arguments to variadic function are promoted to double. So for a function like sprintf / swprintf, you always need to use a double when importing the function or using PrototypeC.
After that, passing a float (.f) works fine as PB will convert ...
After that, passing a float (.f) works fine as PB will convert ...
- Thu Jul 19, 2018 1:55 pm
- Forum: Tricks 'n' Tips
- Topic: Format string with some values like sprintf (C)
- Replies: 62
- Views: 39757
Re: Format string with some values like sprintf (C) - Update
... data as a float ?
FISTP stores the float as an integer which won't work.
But there also seems to be a bug on PureBasic Windows x64.
I can't get swprintf to work cross platform so here's an example with sprintf instead. ImportC ""
sprintf(*str, format.p-ascii, arg1.d=0, arg2.d=0)
EndImport
Global ...
FISTP stores the float as an integer which won't work.
But there also seems to be a bug on PureBasic Windows x64.
I can't get swprintf to work cross platform so here's an example with sprintf instead. ImportC ""
sprintf(*str, format.p-ascii, arg1.d=0, arg2.d=0)
EndImport
Global ...
- Thu Jul 19, 2018 12:55 pm
- Forum: Tricks 'n' Tips
- Topic: Format string with some values like sprintf (C)
- Replies: 62
- Views: 39757
Re: Format string with some values like sprintf (C) - Update
Probably the x64 calling convention.
But it does the same on x86
ImportC ""
swprintf(*str.string,format.s,*args1=0,*args2=0)
EndImport
Global str.s{128}
Global i = 12
Global f.f = 3.14
; FLD dword [v_f]
; PUSH eax
; FISTP dword [esp]
; PUSH dword [v_i]
; MOV eax,_S1
; PUSH eax
; PUSH dword ...
- Wed Jul 18, 2018 10:25 pm
- Forum: Tricks 'n' Tips
- Topic: Format string with some values like sprintf (C)
- Replies: 62
- Views: 39757
Re: Format string with some values like sprintf (C) - Update
... 2
;A Hexadecimal floating point, uppercase -0XC.90FEP-2
;c Character a
;s String of characters sample
;p Pointer address b8000000
ImportC ""
swprintf(*str.string,format.s,*args,*args1=0,*args2=0,*args3=0,*args4=0,*args5=0,*args6=0,*args7=0,*args8=0)
EndImport
Global str.s{128}
Global ...
;A Hexadecimal floating point, uppercase -0XC.90FEP-2
;c Character a
;s String of characters sample
;p Pointer address b8000000
ImportC ""
swprintf(*str.string,format.s,*args,*args1=0,*args2=0,*args3=0,*args4=0,*args5=0,*args6=0,*args7=0,*args8=0)
EndImport
Global str.s{128}
Global ...
- Sat Jul 22, 2017 3:40 pm
- Forum: Feature Requests and Wishlists
- Topic: Native FormatString (sprintf)
- Replies: 12
- Views: 5345
Re: Native FormatString (sprintf)
s.s{1024}
OpenLibrary(0, "MSVCRT.dll")
CallCFunction(0, "swprintf", @s, @"Param %i", 10)
Debug s
Works on Windows, but not on Linux (and probably not on Mac, too).
I would appreciate to have a native cross-platform sprintf() function built-in into PureBasic.
For me, this is especially useful when I ...
OpenLibrary(0, "MSVCRT.dll")
CallCFunction(0, "swprintf", @s, @"Param %i", 10)
Debug s
Works on Windows, but not on Linux (and probably not on Mac, too).
I would appreciate to have a native cross-platform sprintf() function built-in into PureBasic.
For me, this is especially useful when I ...
- Sat Jul 22, 2017 3:20 pm
- Forum: Feature Requests and Wishlists
- Topic: Native FormatString (sprintf)
- Replies: 12
- Views: 5345
Re: Native FormatString (sprintf)
What's wrong with floats?

Code: Select all
ImportC "MSVCRT.LIB"
swPrintf.l(out$, fmt$, Xd.d) As "swprintf"
EndImport
Define.s r$ = StrD(#PI,4) + "ZZZ"
x.d = #PI
Debug r$
Debug x
ShowMemoryViewer(@r$, 32)
Debug swPrintf(r$, "%e", x)
ShowMemoryViewer(@r$, 32)
Debug r$
- Sat Jul 22, 2017 2:17 pm
- Forum: Feature Requests and Wishlists
- Topic: Native FormatString (sprintf)
- Replies: 12
- Views: 5345
Re: Native FormatString (sprintf)
Code: Select all
s.s{1024}
OpenLibrary(0, "MSVCRT.dll")
CallCFunction(0, "swprintf", @s, @"Param %i", 10)
Debug s
- Sat Jun 17, 2017 4:28 am
- Forum: Coding Questions
- Topic: dev-C++ dll howto
- Replies: 9
- Views: 4615
Re: dev-C++ dll howto
... PrototypeC.i ProtoSprintf(Buffer.s, Format.s, Arg1.l = 0, Arg2.l = 0, Arg3.l = 0, Arg4.l = 0)
Global sprintf.ProtoSprintf = GetFunction(lib, "swprintf")
CloseLibrary(lib)
a = 5
n = "About: %d"
buffer = Space(50)
CharsWritten = sprintf(buffer, n, a)
Debug buffer
Debug CharsWritten
Debug Len ...
Global sprintf.ProtoSprintf = GetFunction(lib, "swprintf")
CloseLibrary(lib)
a = 5
n = "About: %d"
buffer = Space(50)
CharsWritten = sprintf(buffer, n, a)
Debug buffer
Debug CharsWritten
Debug Len ...
- Sat Jun 17, 2017 4:18 am
- Forum: Coding Questions
- Topic: C Runtime Library & variable parameters
- Replies: 25
- Views: 11004
Re: C Runtime Library & variable parameters
... PrototypeC.i ProtoSprintf(Buffer.s, Format.s, Arg1.l = 0, Arg2.l = 0, Arg3.l = 0, Arg4.l = 0)
Global sprintf.ProtoSprintf = GetFunction(lib, "swprintf")
CloseLibrary(lib)
a = 5
n = "About: %d"
buffer = Space(50)
CharsWritten = sprintf(buffer, n, a)
Debug buffer
Debug CharsWritten
Debug Len ...
Global sprintf.ProtoSprintf = GetFunction(lib, "swprintf")
CloseLibrary(lib)
a = 5
n = "About: %d"
buffer = Space(50)
CharsWritten = sprintf(buffer, n, a)
Debug buffer
Debug CharsWritten
Debug Len ...
- Wed Apr 03, 2013 1:03 pm
- Forum: Linux
- Topic: 64 bit porting problem
- Replies: 1
- Views: 2283
64 bit porting problem
... snip...]
16814 lines processed.
Creating the executable.
Error: Linker
/usr/bin/ld.bfd.real: /usr/local/purebasic/compilers/unicodefunctions.a(swprintf.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/local/purebasic/compilers ...
16814 lines processed.
Creating the executable.
Error: Linker
/usr/bin/ld.bfd.real: /usr/local/purebasic/compilers/unicodefunctions.a(swprintf.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/local/purebasic/compilers ...
- Sun Feb 14, 2010 10:41 pm
- Forum: Tricks 'n' Tips
- Topic: Format Numbers using sprintf from C library.
- Replies: 1
- Views: 2837
Format Numbers using sprintf from C library.
... required.
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
CompilerIf #PB_Compiler_Unicode
sPrintf.l(result$,format$,num.d) As "_swprintf"
sPrintf_LLD.l(result$,format$,num1.l,num2.l,num.d) As "_swprintf"
CompilerElse
sPrintf.l(result$,format$,num.d) As "_sprintf"
sPrintf_LLD.l ...
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
CompilerIf #PB_Compiler_Unicode
sPrintf.l(result$,format$,num.d) As "_swprintf"
sPrintf_LLD.l(result$,format$,num1.l,num2.l,num.d) As "_swprintf"
CompilerElse
sPrintf.l(result$,format$,num.d) As "_sprintf"
sPrintf_LLD.l ...