Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
C Format function VFP implementation
Message
 
 
À
11/06/2015 05:05:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01620846
Message ID:
01620890
Vues:
78
>>Hi everybody,
>>
>>Just wondering if anyone already implemented C format function in VFP. E.g. replacing %s %s in a string with first and second parameter.
>>
>>If yes and you're willing to share your implementation, that would be great.
>>
>>Thanks a lot in advance.
>
>(1) Simple
>use strtran()
>
>(2) Use api
>
>You will have to define sprintf for each combination of number and type of parameters
>
>
>*_______________________________________________________________________________
>function do_it()
>	
>	
>	local n, out, p1, p2
>	
>	&& (1) 
>	out = space(4096)
>	p1 = 'First'
>	p2 = 'Second'
>
>	n= sPrintf_str_str (@m.out, "Hello %s and %s", m.p1, m.p2)
>	out = left(m.out, m.n)
>	?out
>	
>	&& (2) 
>	out = space(4096)
>	p1 = 'Third'
>	p2 = 'Fourth'
>	
>	n= sPrintf_str_str (@m.out, "Hello %s and %s", m.p1, m.p2)
>	out = left(m.out, m.n)
>	?out
>	
>	&& (3)
>	out = space(4096)
>	p1 = 'Third'
>	p2 = 24
>	
>	n= sPrintf_str_int (@m.out, "Hello %s and %d", m.p1, m.p2)
>	out = left(m.out, m.n)
>	?out
>	
>	&& (4)
>	out = space(4096)
>	p1 = 'Third'
>	p2 = 'Seven'
>	
>	n= sPrintf_str_str (@m.out, "Hello %s and %s", m.p1, m.p2)
>	out = left(m.out, m.n)
>	?out
>endfunc
>*_______________________________________________________________________________
>function sPrintf_str_str( out, sformat, p1, p2)
>
>	declare integer sprintf in msvcrt.dll as sPrintf_str_str ;
>		string@, string, string, string
>		
>	return sPrintf_str_str (@m.out, m.sformat, m.p1, m.p2)
>
>endfunc
>*_______________________________________________________________________________
>function sPrintf_str_int( out, sformat, p1, p2)
>	
>	declare integer sprintf in msvcrt.dll as sPrintf_str_int ;
>		string@, string, string, integer
>		
>	return sPrintf_str_int(@m.out, m.sformat, m.p1, m.p2)
>
>endfunc
>*_______________________________________________________________________________
>
Looks great, Gregory. Thanks a lot.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform