[Note from Lexikos: This and the next few posts were split from Assorted & Unsorted AutoHotkey v2 Wish List to make further discussion easier.]
IMO, one of the reasons people are reluctant to use objects (and thus to have core functionality redesigned to use objects) is because they are forced to use expression syntax, which involves more syntactical noise. In v2, functions can be called with traditional command syntax, alleviating this problem. However there is still no way to use command syntax with objects. Therefore I propose the following syntax:
Code: Select all
obj.Method, Param1, Param2, ... ; CALL operation.
obj.Method:, OutputVar, Param1, Param2, ... ; CALL operation, storing the return value in OutputVar.
obj.Get, OutputVar, Index1, Index2, ... ; GET operation.
obj.Set, Index1, Index2, ..., Value ; SET operation.
Example code:
Code: Select all
; Use a File object
FileOpen, File, MyFile.txt, w
File.Write Hello world!`n
File.Set Pos, 0
File.Read: Line
MsgBox %Line%
; Use a Gui object: http://ahkscript.org/boards/viewtopic.php?f=37&t=2998
GuiCreate, Gui, Progress Example,, MyGui_
Gui.Set BgColor, White
Gui.AddPic, x0 y0 h350 w450, %A_WinDir%\system32\ntimage.gif
Gui.AddButton, Default xp+20 yp+250, Start the Bar Moving
Gui.AddProgress: MyProgress, w416
Gui.AddText: MyText, wp
Gui.Show
MyGui_ButtonStartTheBarMoving()
{
global
Loop Files, %A_WinDir%\*.*
{
if A_Index > 100
break
MyProgress.Set Value, %A_Index%
MyText.Set Value, %A_LoopFileName%
Sleep 50
}
MyText.Set Value, Bar finished.
}