AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   % sign in format? (https://forums.alliedmods.net/showthread.php?t=57058)

Afrow UK 06-27-2007 09:37

% sign in format?
 
How would I go about inserting a % sign in format/formatex etc? I've tried % on it's own, ^%, %% but none of these work. I need to use it with SQL LIKE:

LIKE '%%s%'

Currently I get a run time error 'String formatted incorrectly'.

Stu

Afrow UK 06-27-2007 09:42

Re: % sign in format?
 
Never mind. The problem was because I was using formatex to create my query string and then passing that variable onto SQL_PrepareQuery, which also uses format and the %'s already in the string were causing the error.

Stu

teame06 06-27-2007 16:05

Re: % sign in format?
 
To escape the % in format you need to do %%.

Code:
format(hi, sizeof(hi) - 1, "%s%%", "Hi");


All times are GMT -4. The time now is 21:30.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.