Jump to content

Static & ByRef


Recommended Posts

@JohnOne

I thought a bit about  your suggestion using objects and it turns out I have done you wrong:

main()

Func main($key = "")

    $oResult = test()

    test()  ; the more calls from any other possible locations you make...
    test()  ; ...the higher the number will be.

    ; So test() has permanent access to a "variable" in main()    > mission accomplished!
    ConsoleWrite( "asynchronous result: " & $oResult.Item("")   & @LF )

EndFunc

Func test()

    Static $oResult

    if not( IsObj( $oResult ) ) Then
       $oResult = ObjCreate( "Scripting.Dictionary" )
       $oResult.ADD("" , 1 )
       return $oResult
   Else
       $cache = $oResult.Item("")
       $oResult.REMOVE("")
       $oResult.ADD("" , $cache + 1 )
    EndIf

EndFunc

This works just well and does what I want. Maybe the dictionary is not the ultimate solution but in principle it is a solution to the original request.
 Thank you  & merry christmas

ps: if anyone knows a better object let me know please. ( What I mean by that is an object that direclty represents a  variable so that no fcn-call like ".item( "" )" is needed )

Edited by Bluesmaster

My UDF: [topic='156155']_shellExecuteHidden[/topic]

Link to comment
Share on other sites

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I added new data type to AutoIt while I was developer, called Table. It's supercool thingy which unfortunatly I wasn't able to finish implementing. Instead new/old developer (red Jon) removed some details probably to hide it from users until he figures out what to do with it.
Still with latest beta it's possible to do this (even though it was more correct before when IsTable function existed):

main()

Func main($key = "")

    test() ; 1
    test() ; 2
    test() ; 3
    test() ; 4

    ConsoleWrite("result: " & test() & @LF) ; prints 5
    ConsoleWrite("result: " & test() & @LF) ; prints 6

EndFunc

Func test()
    Local Static $x

    If Not (VarGetType($x) = "Table") Then
        Local $y[]
        $x = $y
        $x.elem = 0
    EndIf

    $x.elem += 1
    Return $x.elem
EndFunc

...not that it has anything to do with your question, LOL.

But this could have:

main()

Func main($key = "")

    $a = test() ; 1
    test() ; 2
    test() ; 3
    test() ; 4
    test() ; 5
    test() ; 6

    ConsoleWrite("result: " & $a.elem & @LF) ; prints 6 ;<- Aha!

EndFunc

Func test()
    Local Static $x

    If Not (VarGetType($x) = "Table") Then
        Local $y[]
        $x = $y
        $x.elem = 0
    EndIf

    $x.elem += 1
    Return $x
EndFunc
Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Well this seems to work. But I am a bit concerned if this is not too experimental. I could not find any posting to this new data type

and the story of its development sounds like an adventure :)  So how can I be sure this feature will not be removed in the next release crashing all my dependend code?

( independend opinions welcome )

So one creates a "table" ( most languages do know this as struct or? ) by using:

$myVar[]  ...right?

What is under the hood there that it behaves more like an object than an ordinary autoit-variable ( as shown in the example )?

 

best regards

Blues

Edited by Bluesmaster

My UDF: [topic='156155']_shellExecuteHidden[/topic]

Link to comment
Share on other sites

Well, Jon pretty much knows that Table type is awesome feature. He is also bit afraid not to hurt my feelings more by removing it (God almighty knows where he got that idea) and he's kind of lazy to work on it, besides he doesn't wan't to fuck up something else if he starts playing with the code. So, it's kind of status quo on that.

Experimental features are made for experimenting. Experiment then, I say.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

  • Moderators

Bluesmaster,

The Table datatype disclosed by trancexx is undocumented, not experimental, and therefore does not exist as far as official AutoIt development is concerned. So it could be removed without warning from any future release, there is absolutely no guarantee of it perfoming in any manner whatsoever, and there will certainly be no bug fixes or changes. You use it entirely at your own risk.

Personally I think Tables could be a very useful addition to the language - but you need to appreciate the current position of this feature before getting dependent on 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

  • Moderators

Bluesmaster,

And as I warned, the Table datatype is not in the 3.3.10.0 release. ;)

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

  • Moderators

Bluesmaster,

The comment was not directed at you, so it is not surprising that you do not understand it. I suggest you ignore the post completely, which is all it deserves. :)

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

In the risk of sounding a bit retarded: I do not understand what you mean by that.

You don't sound retarded, don't worry. The comment wasn't for you, otherwise I would've quoted your post.

It was for one who understood it the second after reading it. One who thinks he can play with me, not realizing I'm step ahead. :)

Fun way of making people do what you want them to, because sometimes they deserve just that. At the end AutoIt wins, so no sweat.

♡♡♡

.

eMyvnE

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