SA-MP Forums Archive
GetScriptLine() or something? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: GetScriptLine() or something? (/showthread.php?tid=192998)



GetScriptLine() or something? - TheXIII - 24.11.2010

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();
}



Re: GetScriptLine() or something? - WillyP - 24.11.2010

I don't see why this would be useful?


Re: GetScriptLine() or something? - TheXIII - 24.11.2010

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.


Re: GetScriptLine() or something? - WillyP - 24.11.2010

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'.


Re: GetScriptLine() or something? - Jochemd - 24.11.2010

It's impossible. Nothing else.


Re: GetScriptLine() or something? - RyDeR` - 24.11.2010

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


Re: GetScriptLine() or something? - Hiddos - 24.11.2010

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.


Re: GetScriptLine() or something? - TheXIII - 24.11.2010

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...


Re: GetScriptLine() or something? - RyDeR` - 24.11.2010

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


Re: GetScriptLine() or something? - TheXIII - 24.11.2010

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?