[Tool/Web/Other] #define a 10 | public cmd_a+1 | public cmd_a+2 | - NOW POSSIBLE! - [beta] - Gamer_Z's PawnPreProcessor | v0.1
#1

NOTE: All repositories moved from googlecode to Github: http://gpb.gz0.nl/
Yes it's possible now thanks to my program (which is in beta , any code contributions are welcome!).

First of all, you all know I'm just a hobby programmer, NO PRO! So don't flame me for bad code, but explain why it is bad code and suggest/contribute something! Else don't comment the source. Ok? Let's go on..


Look at this:
pawn Code:
#include <a_samp>
#define zcmd:%0(%1,%2) forward zcmd_%0(%1,%2);public zcmd_%0(%1,%2)
#adder TEST_x   (   100 )
public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

forward cmd_TEST_x    +     1(param);//note the spaces etc
public cmd_TEST_x    +      1(param)
{
    return 1;
}
forward cmd_TEST_x(param);
public cmd_TEST_x(param)
{
    return 1;
}

forward cmd_TEST_x+ 65456(param);
public cmd_TEST_x    +      65456(param)
{
    return 1;
}
zcmd:TEST_x+50(playerid,cmdtext[])
{
    return 1;
}
you see the #adder directive, that is a special directive dedicated for this program.
The program is very simple so do not use any weird syntaxt or comments between definitions (from now on 'adders')!
Keep it simple and clean so you won't crash the program.

after my preprocessor is done the code will look like:
pawn Code:
#include <a_samp>
#define zcmd:%0(%1,%2) forward zcmd_%0(%1,%2);public zcmd_%0(%1,%2)

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    printh(" Blanhk Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

forward cmd_101(param);
public cmd_101(param)
{
    return 1;
}
forward cmd_100(param);
public cmd_100(param)
{
    return 1;
}

forward cmd_65556(param);
public cmd_65556(param)
{
    return 1;
}
zcmd:50556(playerid,cmdtext[])
{
    return 1;
}
you can see it's still a little buggy, but we will fix it together.. the code compiles fine .
The best part is, now you can enjoy the speed of FDLG and named dialogs together!

Note 1: I am not responsible in ANY way for damage caused by this preprocessor program.
Note 2: You need Microsoft C++ Redistributable 2010 32 bit edition and .NET Framework 2.0

Installation:
The Gamer_Z's PawnPreProcessor package is part of the GPB project, you can obtain it from: http://code.google.com/p/gpb/downloads/list ( http://gpb.googlecode.com )

Download the package, after unzipping it to anywhere you have two folders:
Pawno and Source.
the source is obivious - the program's code.
The pawno folder contains the files you need to copy to your original pawno folder you are using.
If you have an modified (apart from the sa-mp.com's version) version of pawncc.exe change the name to pawncco.exe and then only copy over the pawncc.exe from the package pawno folder to your own pawno folder, else you can just copy all files.

Waiting for feedback from ya all, have fun
and remember, contribute code, help improving if you can!
Reply
#2

Yet again nice work! I would not probably use it, but I highly recommend it.
Reply
#3

What does it do?
Reply
#4

Quote:
Originally Posted by Ballu Miaa
View Post
What does it do?
Did you read the #1 post at all?(!)
Reply
#5

Quote:
Originally Posted by Gamer_Z
View Post
Did you read the #1 post at all?(!)
I don't understand this too. I mean, what is this useful for? I see no logic in what your pre-processor/program does.
pawn Code:
forward cmd_TEST_x    +     1(param);
becomes
pawn Code:
forward cmd_101(param);

pawn Code:
public cmd_TEST_    +       1(param)
becomes
pawn Code:
public cmdb_101(param)
WHAT?!
Reply
#6

It calculates the value of TEST_x (defined 100) plus 1 and then converts the whole thing to a string or something. However, I don't see any usefulness in this either. If Gamer_Z can provide me with a real world example to demonstrate its true usefulness (i.e. something that can't be done with the current preprocessor directives), I might come back on my opinion.
Reply
#7

I don't understand how "cmd_TEST_ + 1" suddenly becomes "cmdb_101". Where the heck that 'b' comes from?

Gamer_Z, unless the purpose of a tool is obvious, you gotta include some description.
Reply
#8

Quote:
Originally Posted by Vince
View Post
It calculates the value of TEST_x (defined 100) plus 1 and then converts the whole thing to a string or something. However, I don't see any usefulness in this either. If Gamer_Z can provide me with a real world example to demonstrate its true usefulness (i.e. something that can't be done with the current preprocessor directives), I might come back on my opinion.
pawn Code:
#include <fdialog>
#adder MyFDialogIDBase 100

fDialog(MyFDialogIDBase+1)
{
    if(!response)return 1;
    ShowPlayerDialog(
        playerid,
        MyFDialogIDBase+2,
        DIALOG_STYLE_INPUT,
        "Registration",
        "Please provide an password for your account:",
        "Check",
        "Abort"
    );
    return 1;
}

fDialog(MyFDialogIDBase+2)
{
    if(!response)return 1;
    new strlenv = strlen(inputtext);
    if(strlenv > 90 || strlenv < 6)
    {
        ShowPlayerDialog(
            playerid,
            MyFDialogIDBase+2,
            DIALOG_STYLE_INPUT,
            "Registration",
            "Your password should be between 6 and 90 characters long!",
            "Check",
            "Abort"
        );
        return 1;
    }

    format(AUTHREG[playerid][Password],90,"%s",inputtext);

    ShowPlayerDialog(
        playerid,
        MyFDialogIDBase+3,
        DIALOG_STYLE_INPUT,
        "Registration",
        "Please provide your E-Mail adres for password recovery:",
        "Next",
        "Abort"
    );
    return 1;
}
With the normal compiler it isn't possible when you change "adder" to "define"

output:
pawn Code:
#include <fdialog>


fDialog(101)
{
    if(!response)return 1;
    ShowPlayerDialog(
        playerid,
        102,
        DIALOG_STYLE_INPUT,
        "Registration",
        "Please provide an password for your account:",
        "Check",
        "Abort"
    );
    return 1;
}

fDialog(102)
{
    if(!response)return 1;
    new strlenv = strlen(inputtext);
    if(strlenv > 90 || strlenv < 6)
    {
        ShowPlayerDialog(
            playerid,
            102,
            DIALOG_STYLE_INPUT,
            "Registration",
            "Your password should be between 6 and 90 characters long!",
            "Check",
            "Abort"
        );
        return 1;
    }

    format(AUTHREG[playerid][Password],90,"%s",inputtext);

    ShowPlayerDialog(
        playerid,
        103,
        DIALOG_STYLE_INPUT,
        "Registration",
        "Please provide your E-Mail adres for password recovery:",
        "Next",
        "Abort"
    );
    return 1;
}
Quote:
Originally Posted by CaHbKo
View Post
I don't understand how "cmd_TEST_ + 1" suddenly becomes "cmdb_101". Where the heck that 'b' comes from?

Gamer_Z, unless the purpose of a tool is obvious, you gotta include some description.
that was a little mistake.
Reply
#9

I get it slowly.

Purpose of this is to be able to do math in function names?
Reply
#10

Quote:
Originally Posted by CaHbKo
View Post
I get it slowly.

Purpose of this is to be able to do math in function names?
something like that, yes..
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)