GetScriptLine() or something?
#1

Wondering if such a function exists or is possible to create.
The idea is to output the script line where the code is for debugging purposes.
Also wondering if it's possible to assign it as a function parameter default value. Something like this:
pawn Код:
public Function(someID, someString[], LineCalled = GetScriptLine())
{
    if( Some_error == true )
    {
        printf("Error occured with function "Function"; Called from line %i", LineCalled);
    }
    else return ProceedNormally();
}
Reply
#2

I don't see why this would be useful?
Reply
#3

Quote:
Originally Posted by [FU]Victious
Посмотреть сообщение
I don't see why this would be useful?
Quote:
Originally Posted by TheXIII
Посмотреть сообщение
The idea is to output the script line where the code is for debugging purposes.
I bet all of you have seen errors like "Error occured on line #n", in PHP or some application etc. Just wondering if it's possible to have it in PAWN, is all.
Reply
#4

Quote:
Originally Posted by TheXIII
Посмотреть сообщение
I bet all of you have seen errors like "Error occured on line #n", in PHP or some application etc. Just wondering if it's possible to have it in PAWN, is all.
I think I saw something like this before. I'm sure it would be possible, but I don't have a clue on how to do it myself - so all I gotta say to you is 'Good luck'.
Reply
#5

It's impossible. Nothing else.
Reply
#6

As far as I understood, you want to store all data you read from line 'x'?
Possible. Even very simple.
Reply
#7

Quote:
Originally Posted by RyDeR`
Посмотреть сообщение
As far as I understood, you want to store all data you read from line 'x'?
Possible. Even very simple.
He wants the samp-server.exe thingy w/e it may be to print a specific from the script once it gets reached and errors.
Reply
#8

Quote:
Originally Posted by RyDeR`
Посмотреть сообщение
As far as I understood, you want to store all data you read from line 'x'?
Possible. Even very simple.
No, not read or execute or store a specific line or anything like that. But get the actual line number of the script where this function is.
Like so:
pawn Код:
//Start of the file, Line 1.
main () //Line 2
{ // Line 3
// Line 4
} // Line 5
// Line 6
PrintCurrentLine() // Line 7
{ // Line 8
    return printf("Current Line: %i", GetScriptLine()); //Line 9, prints to console: "Current Line: 9"
} // Line 10

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
It's impossible. Nothing else.
You 100% sure? It is possible, that it's impossible (lol), but it's also possible that there might just be a way, just noone really uses it, so a few know about it.

If there is such a thing it is probably not a function, but some kind of instruction for compiler.
There is a Directive "#line" available. But this is what the wiki says about it:
Код:
#line

This is another mostly useless directive like #file. It just specifies the current line number if you feel the need to change it.
And that is not really it. But it's kinda close...
Reply
#9

Ah, so if you put GetScriptLine(); somewhere and wants to print it, it should print the part where GetScriptLine() is added?
Possible.
Reply
#10

Quote:
Originally Posted by RyDeR`
Посмотреть сообщение
Ah, so if you put GetScriptLine(); somewhere and wants to print it, it should print the part where GetScriptLine() is added?
Possible.
Yeah, exactly. Possible, but how?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)