Jump to content

index lines


Recommended Posts

I want to know if is possible to get current line from my script.

For example:

GUICreate("TEST",200,200,-1,-1)
$BUTTON = GUICtrlCreateButton("EXIT",50,80,100,40)
GUISetState(@SW_SHOW)
Line()
While 1
    $MSG = GUIGetMsg()
    If $MSG = -3 Then Exit
    Sleep(25)
WEnd

Func Line()
    ...
EndFunc

And Line function return the number of current line, in this case 4.

Any ideas?

When the words fail... music speaks.

Link to comment
Share on other sites

I want to know if is possible to get current line from my script.

For example:

GUICreate("TEST",200,200,-1,-1)
$BUTTON = GUICtrlCreateButton("EXIT",50,80,100,40)
GUISetState(@SW_SHOW)
Line()
While 1
    $MSG = GUIGetMsg()
    If $MSG = -3 Then Exit
    Sleep(25)
WEnd

Func Line()
    ...
EndFunc

And Line function return the number of current line, in this case 4.

Any ideas?

Only in a script. Not a compiled script.

See the macro @ScriptLineNumber in the help file.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

TrayIconDebug

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

And is no other way to get line number?

Is there some special reason to know the line number?
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Some time ago I programming QBasic and there is TRON command, I want a command like that.

Yes I understand that you want it but I just wondered if there was some special reason, like was it for debugging the script for example.

Why is @ScriptLineNumber no good, or TrayIconDebug no good? Do you need it for a compiled script?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Yes I understand that you want it but I just wondered if there was some special reason, like was it for debugging the script for example.

Why is @ScriptLineNumber no good, or TrayIconDebug no good? Do you need it for a compiled script?

Yes, I want to use for a compiled script but if is not possible I will search for other ways to do that.

Thanks martin and Xenobiologist for help!

When the words fail... music speaks.

Link to comment
Share on other sites

Yes, I want to use for a compiled script but if is not possible I will search for other ways to do that.

Thanks martin and Xenobiologist for help!

Here's a suggestion

Step one, you have a function which must be called LineOutFunc that you use to deal with the line number. It could be like this

Func LineOutFunc($ll);$ll is the line number
    ToolTip("line = " & $ll,0,0)
EndFunc

and you save this function in a script of it's own called LineOut.au3, and you make sure that it's saved in the same folder as the script you want to compile with line numbers.

Then you use this script

$sf = FileOpen(FileOpenDialog("script to compile with line numbers", "\", "AutoIt Script (*.au3)"), 0)
$opname = InputBox("Enter name for compiled script", "exe name?")
$of = FileOpen($opname & ".au3", 2)
FileWriteLine($of, '#include "LineOut.au3"');contains your function to handle to line number
$lcount = 0
$lastline = ''
While 1
    $nextl = FileReadLine($sf)
    If @error Then ExitLoop
    $lcount += 1
    If StringRight($lastline, 2) <> " _" Then
        FileWriteLine($of, "LineOutFunc(" & $lcount & ")")
    EndIf
    
    FileWriteLine($of, $nextl)
    $lastline = $nextl
WEnd

FileClose($of)
FileClose($sf)

This will produce a new script with the name you chose. Compile it and you will get the line numbers shown if you use my example function.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Here's a suggestion

Step one, you have a function which must be called LineOutFunc that you use to deal with the line number. It could be like this

Func LineOutFunc($ll);$ll is the line number
    ToolTip("line = " & $ll,0,0)
EndFunc

and you save this function in a script of it's own called LineOut.au3, and you make sure that it's saved in the same folder as the script you want to compile with line numbers.

Then you use this script

$sf = FileOpen(FileOpenDialog("script to compile with line numbers", "\", "AutoIt Script (*.au3)"), 0)
$opname = InputBox("Enter name for compiled script", "exe name?")
$of = FileOpen($opname & ".au3", 2)
FileWriteLine($of, '#include "LineOut.au3"');contains your function to handle to line number
$lcount = 0
$lastline = ''
While 1
    $nextl = FileReadLine($sf)
    If @error Then ExitLoop
    $lcount += 1
    If StringRight($lastline, 2) <> " _" Then
        FileWriteLine($of, "LineOutFunc(" & $lcount & ")")
    EndIf
    
    FileWriteLine($of, $nextl)
    $lastline = $nextl
WEnd

FileClose($of)
FileClose($sf)

This will produce a new script with the name you chose. Compile it and you will get the line numbers shown if you use my example function.

I like your idea, thank you martin for all help!

When the words fail... music speaks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...