SA-MP Forums Archive
preprocessor problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: preprocessor problem (/showthread.php?tid=629505)



preprocessor problem - ATomas - 27.02.2017

Hello,
i have problem with #define and replacing special characters in compile time
(from:
ě љ č ř ћ э б н й
to:
e s c r z y a i e)

in coplile time, NOT real time.

I have function PrintTest with constant string parameter

Код:
public OnFilterScriptInit()
{
	PrintTest("pбpěp");//i need rewrite to: papep
	PrintTest("pбrб");//para
	PrintTest("jeћнљ");//jezis
	PrintTest("paraљutista");//parasutista
	PrintTest("mlйko");//mleko
	PrintTest("ћбdnб");//zadna
	//etc. many use 1 000 000 times in code. Wery hard for rewriting
	return 1;
}
I try use define like this:
Код:
#define PrintTest("%0б%1")  PrintTest(#%0a#%1)

//for string "pбrб" replace "parб" NOT "para" what i need
I try use define like this:
Код:
#define PrintTest("%0ě%1")  PrintTest(#%0e#%1)
#define PrintTest("%0б%1")  PrintTest(#%0a#%1)

//for string "pбpěp" replace "papěp" NOT "papep" what i need. And in compile show error warning 201: redefinition of constant/macro (symbol "PrintTest("%0б%1")")
I try use define like this:
Код:
#define ě e

//In compile show error 074: #define pattern must start with an alphabetic character
How to write define to replace this special characters?
Thanks for any help


Re: preprocessor problem - Runn3R - 27.02.2017

Use notepad++.


Re: preprocessor problem - Misiur - 27.02.2017

Long story short: you can't do it this way. The way preprocessor works, you can't match a single letter in a word. IIRC this thread describes what the preprocesor is looking for


Re: preprocessor problem - ATomas - 27.02.2017

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Long story short: you can't do it this way. The way preprocessor works, you can't match a single letter in a word. IIRC this thread describes what the preprocesor is looking for
Its means, i cant use preprocessor for this problem?


Re: preprocessor problem - Misiur - 27.02.2017

Nope, unless you can recreate ******'s magic https://github.com/Misiur/YSI-Includ....inc#L176-L239


Re: preprocessor problem - ATomas - 27.02.2017

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Nope, unless you can recreate ******'s magic https://github.com/Misiur/YSI-Includ....inc#L176-L239
Eh.... I dont understand this code. Can you give me example with character ě (ě -> e)?

Thank you


Re: preprocessor problem - renatog - 27.02.2017

You can't do that via preprocessor, but you can use replace function from your code editor. I don't know what you use, but in Atom we can find and replace a text of all files in a directory. You can use this feature to replace all (ě) to (e) or any other character.


Re: preprocessor problem - ATomas - 27.02.2017

Quote:

I don't know what you use

I suppose that in the future kalcor the new version of the SA-MP textdraw create the possibility to adjust the font as an object and assign encoding (or will be using UTF). Therefore, you want to permanently delete characters, but preprocessor to solve it temporarily, then just delete preprocessor and go I'm done.


Re: preprocessor problem - ATomas - 28.02.2017

Thank you ****** its works !