Jump to content

#forceref [Answered]


Recommended Posts

  • Moderators

Hi,

I have just stumbled on the #forceref directive/command/statement in some of the more complex examples in the Help file. It seems pretty obvious what it does, and testing by adding it in some of my scripts has certainly reduced the number of "Warning" calls when I run/compile scripts including GUIRegisterMsg functions. But I cannot find any documentation for it in either AutoIt or SciTE - does any exist? Are the variables added to a list somewhere within SciTE? Are there any pitfalls I should be aware of?

Thanks in advance for any enlightenment.

M23

Edit: Answered - see below!

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hi,

I have just stumbled on the #forceref directive/command/statement in some of the more complex examples in the Help file. It seems pretty obvious what it does, and testing by adding it in some of my scripts has certainly reduced the number of "Warning" calls when I run/compile scripts including GUIRegisterMsg functions. But I cannot find any documentation for it in either AutoIt or SciTE - does any exist? Are the variables added to a list somewhere within SciTE? Are there any pitfalls I should be aware of?

Thanks in advance for any enlightenment.

M23

The #ForceRef directive looks like a compiler (AutoIt3Wrapper.exe interprets to Aut2Exe.exe) directive, but it's not. It actually belongs to the syntax checker (AU3Check.exe), which has no help file of its own. The only mention in the SciTE4AutoIt3 help file I can find for #ForceRef is in the change log:

3/11/2006

*** Updated installer with SciTE v1.68. (Neil Hodgson)

*** Updated Au3Check v1.54 (Tylo):

1.54 : Added: Support for #compiler_plugin_funcs= directive. Replaced -U option with -v 3.

1.53 : Fixed: Extended block nesting levels from 20 to 128.

Added: Allow callback args in Call(). Replace the line %Call 1 to %Call 1 in the .dat file for this to work.

1.52 : change: -U outputs an improved linebased list. -u removed. #uses directive changed to #forceref.

Perhaps a new section in the Scite4AutoIt3.chm file under Contents|Extra Utilities|AutoIt3Wrapper|AU3Check (along with the entries for Obfuscator, Tidy, etc.) could be added.

^_^

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • Moderators

PsaltyDS,

Thank you for that much - at least I now know where it comes from!

Calling Jos..... :-)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Developers

Au3check was initially distributed in my SciTE4AutoIt3 installer and that is why it still contains the updates in the history log.

I think au3check should now be documented in the AutoIt3 Helpfile since it distributed together with each new release.

As far as the documentation available: Tylo only provided the attached readme.txt file which I have maintained with the minor fixes/change I have done since Tylo's absence.

Did I hear anyone volunteering to make a htm file out of it with some examples we can include in the helpfile?

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

Jos,

Now I know where to look I came up with these extracts from Tylo's Au3Check thread:

Jan 22 2006

au3check v1.51: 

added: new directive: #uses follwed by a comma separated list of function and/or variable names. It serves two purposes:
to prevent unused local vars warnings (-w 5) 
to force inclusion of symbols in the used list (-u)

; -------

Jan 26 2006
v1.52 released. 

The directive #uses introduced in 1.51 is now renamed to #forceref[]. Again it has two purposes, one is to avoid -w 5 warnings[...]
The other purpose [...] is to avoid global variables and functions to appear in the unreference symbols list, e.g. if called via Call($fn).

My question is answered - my thanks to you and PsaltyDS.

As to the AutoIt3 Help file, I would have thought a simple explanation and an example showing it in a GUIRegisterMsg context would be enough. I do not know much about htm authoring, but if you send me an example of an existing simple page (perhaps #ce?) I would be happy to try and modify it.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Would one of you guys mind making a short demo, with/without #forceref[]

and posting it in the examples section . . . so that we can see the benifit.

Good to have till its in the help file also . . . Thanks! -maybe add some keywords for those errors when not used (For search purposes)

Link to comment
Share on other sites

  • Moderators

Hatcheda,

You are quite right - and here is an example of when #forceref might be useful.

If you use GUIRegisterMsg, you must use 4 parameters - normally $hWnd, $iMsg, $iwParam and $ilParam. If you run Au3Check with the preset (in SciTE) parameters, you will often find that there will be warnings produced saying that some of the parameteres are "declared but not used" - or something similar. This is because, depending on the function, you normally need only some of the parameters to determine the result - the others are only present because of the way GUIRegisterMsg source code has been constructed behind the scenes (not a complaint by the way!).

Here is an example from the Helpfile page for _GUICtrlDTP_Create (which is where I noticed it for the first time):

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $tBuffer, $tBuffer2

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")

As you can see, the only parameter that is used by the code is $ilParam - so normally you would get warnings for the other 3. Using #forceref with a list of the unused parameters prevents these warnings. There is no difference to the functioning of the code, but it means that the script runs/compiles without the warnings. If there are a lot of them, they might obscure more vital warnings/errors - and anyway I prefer to have a warning/error free script. :-)

I hope this is clear enough - my own understanding goes no further!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Developers

Do a CTRL+F5 on these 2 scripts From SciTE and check the Output pane:

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -v 3
Global $a
;
Func Test($x)
    Local $y
    Return
EndFunc

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -v 3
Global $a
#forceref $a,Test
;
Func Test($x)
    Local $y
    #forceref $x,$y
    Return
EndFunc

Can't make it more basic ^_^

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Do a CTRL+F5 on these 2 scripts From SciTE and check the Output pane:

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -v 3
Global $a
;
Func Test($x)
    Local $y
    Return
EndFunc

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -v 3
Global $a
#forceref $a,Test
;
Func Test($x)
    Local $y
    #forceref $x,$y
    Return
EndFunc

Can't make it more basic ^_^

Thank you! I can see where I already had need for this! - good to know!

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