jaberwacky Posted June 13, 2014 Share Posted June 13, 2014 I have the following function which does seem to work as intended. However, AU3Check throws the errors listed below. Func _mouse_position(Const $l_param) With DllStructCreate($tagPOINT & ";dword;dword;dword;ulong_ptr;", $l_param) Local Const $position = [Abs(.X), Abs(.Y)] EndWith Return $position EndFunc "....au3"(395,8) : error: syntax error With DllStructCreate ~~~~~~~^ "....au3"(395,8) : error: Statement cannot be just an expression. With DllStructCreate ~~~~~~~^ "....au3"(396,36) : error: Object method or attribute accessed without 'With'. Local Const $position = [Abs(.X) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "....au3"(396,45) : error: Object method or attribute accessed without 'With'. Local Const $position = [Abs(.X), Abs(.Y) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ "....au3"(397,3) : error: syntax error EndWith ~~^ "....au3"(397,3) : error: Statement cannot be just an expression. EndWith ~~^ Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
kylomas Posted June 13, 2014 Share Posted June 13, 2014 jaberwacky, Apologies if I am missing the point but, if this what you are trying to do??? consolewrite(_get_mouse_pos() & @lf) func _get_mouse_pos() return 'x coord = ' & abs(MouseGetPos()[0]) & '...y coord = ' & abs(MouseGetPos()[1]) endfunc kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jaberwacky Posted June 14, 2014 Author Share Posted June 14, 2014 $l_param stores a dllstruct which already has the coords in it. That's why I do it like this. I figure, why not? Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Malkey Posted June 14, 2014 Share Posted June 14, 2014 (edited) ...Func _mouse_position(Const $l_param) With DllStructCreate($tagPOINT & ";dword;dword;dword;ulong_ptr;", $l_param) Local Const $position = [Abs(.X), Abs(.Y)] EndWith Return $position EndFunc.....I believe AutoIt's C/C++ style structure does not use the dot-accessible type of variable. Therefore, the With...EndWith cannot be used.And, when declaring an array, the size of the array is necessary "Local $position[2] = [ ..,..]" $l_param stores a dllstruct which already has the coords in it. That's why I do it like this. I figure, why not?$l_param is a pointer to a dllstruct.This example works.#include <Array.au3> Global Const $tagPOINT = "struct; long X;long Y; endstruct" Local $param = DllStructCreate($tagPOINT) DllStructSetData($param, "X", 22) DllStructSetData($param, "Y", 33) Local $a = _mouse_position(DllStructGetPtr($param)) _ArrayDisplay($a) Func _mouse_position($l_param) Local $struct = DllStructCreate($tagPOINT, $l_param) ; Local $arr[2] = [DllStructGetData($struct, "X"), DllStructGetData($struct, 2)] Return $arr EndFunc ;==>_mouse_positionEdit: Two "not"'s and the line about the array declaration crossed out because of new found knowledge. Edited June 16, 2014 by Malkey Link to comment Share on other sites More sharing options...
jchd Posted June 15, 2014 Share Posted June 15, 2014 I believe AutoIt's C/C++ style structure does not use the dot-accessible type of variable. Therefore, the With...EndWith cannot be used. And, when declaring an array, the size of the array is necessary "Local $position[2] = [ ..,..]" Sorry but it's no, no and no, respectively. Using the latest release: Local $param = DllStructCreate($tagPOINT) With $param .X = 22 .Y = 33 EndWith Local $a = _mouse_position(DllStructGetPtr($param)) _ArrayDisplay($a) Func _mouse_position($l_param) Local $struct = DllStructCreate($tagPOINT, $l_param) ; Local $arr = [$struct.X, $struct.Y] Return $arr EndFunc ;==>_mouse_position One thing though: we can't use With around the array declaration (yet): Local $arr = [$struct.X, $struct.Y] ; works With $struct ; doesn't work Local $arr = [.X, .Y] EndWith This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
jaberwacky Posted June 15, 2014 Author Share Posted June 15, 2014 One thing though: we can't use With around the array declaration (yet): Local $arr = [$struct.X, $struct.Y] ; works With $struct ; doesn't work Local $arr = [.X, .Y] EndWith You're sure? It works for me. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted June 15, 2014 Share Posted June 15, 2014 $struct.X, $struct.YI don't believe this is "officially" supported. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
trancexx Posted June 15, 2014 Share Posted June 15, 2014 That's irrelevant guinness. The code shows correct syntax which AU3Check can't cope with. Therefore it's a bug in AU3Check. As for the interpreter, array initialization obviously has bug. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
guinness Posted June 15, 2014 Share Posted June 15, 2014 (edited) The fact it works by the interpreter is irrelevant. If it's not documented then it's an undocumented feature and therefore is a bug with the interpreter allowing it to run before it is documented. Edited June 15, 2014 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
trancexx Posted June 15, 2014 Share Posted June 15, 2014 The fact it works by the interpreter is irrelevant. If it's not documented then it's an undocumented feature and therefore is a bug with the interpreter allowing it to run before it is documented. Get a grip. It's forest and the trees thing. With ObjCreate("Shell.Application") Local $aArr = [.GetSystemInformation("DirectoryServiceAvailable"), _ .GetSystemInformation("ProcessorLevel"), _ .GetSystemInformation("ProcessorArchitecture"), _ .GetSystemInformation("PhysicalMemoryInstalled")] EndWith For $vElem In $aArr ConsoleWrite($vElem & @CRLF) Next ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
guinness Posted June 15, 2014 Share Posted June 15, 2014 You really need to learn some manners and if you can't then go and play somewhere else. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
trancexx Posted June 15, 2014 Share Posted June 15, 2014 Oho! This is new. What I "need" isn't for you to say. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
hiho Posted June 15, 2014 Share Posted June 15, 2014 Get a grip. It's forest and the trees thing. With ObjCreate("Shell.Application") Local $aArr = [.GetSystemInformation("DirectoryServiceAvailable"), _ .GetSystemInformation("ProcessorLevel"), _ .GetSystemInformation("ProcessorArchitecture"), _ .GetSystemInformation("PhysicalMemoryInstalled")] EndWith For $vElem In $aArr ConsoleWrite($vElem & @CRLF) Next trancexx, i'm sorry if the question is stupid, but what output is supposed to return? For me, using 3.3.8.1 (not sure if the above code needs a higher Autoit version), it's gives error. Only Object-type variables allowed in a "With" statement.: With ObjCreate("Shell.Application") With ^ ERROR Link to comment Share on other sites More sharing options...
trancexx Posted June 15, 2014 Share Posted June 15, 2014 ^^ 3.3.8.1. is two and a half years old software. AutoIt interpreter was developed further in the meantime. It should print 4 info. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
mikell Posted June 15, 2014 Share Posted June 15, 2014 Running 3.3.12.0 The first part (commented) causes no error but returns an empty 4 elts array, while the 2nd part works #Include <Array.au3> #cs With ObjCreate("Shell.Application") Local $aArr = [.GetSystemInformation("DirectoryServiceAvailable"), _ .GetSystemInformation("ProcessorLevel"), _ .GetSystemInformation("ProcessorArchitecture"), _ .GetSystemInformation("PhysicalMemoryInstalled")] EndWith #ce ;#cs $o = ObjCreate("Shell.Application") Local $aArr = [$o.GetSystemInformation("DirectoryServiceAvailable"), _ $o.GetSystemInformation("ProcessorLevel"), _ $o.GetSystemInformation("ProcessorArchitecture"), _ $o.GetSystemInformation("PhysicalMemoryInstalled")] ;#ce _ArrayDisplay($aArr) Link to comment Share on other sites More sharing options...
jchd Posted June 15, 2014 Share Posted June 15, 2014 Yup. Beside the array initializer silently ignoring it, the dot notation works and has been working for ages. This has been discussed many times before without anyone objecting a bug. I may be wrong but by the time it has been working this way I believe it's now more a lack of documentation "issue". This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Developers Jos Posted June 15, 2014 Developers Share Posted June 15, 2014 (edited) Simple example to demo what was just stated. The last 2 are considered invalid by au3check which needs looking at. #AutoIt3Wrapper_Run_AU3Check=n #Include <Array.au3> ; $o = ObjCreate("Wscript.Network") Local $aArr = [$o.UserName, $o.UserDomain, $o.ComputerName] _ArrayDisplay($aArr,"Example 1 - Works") ; With $o Local $aArr[3] $aArr[0] = .UserName $aArr[1] = .UserDomain $aArr[2] = .ComputerName EndWith _ArrayDisplay($aArr,"Example 2 - Works") ; With $o Local $aArr = [ .UserName, .UserDomain, .ComputerName] EndWith _ArrayDisplay($aArr,"Example 3 - Nope") ; With ObjCreate("Wscript.Network") Local $aArr[3] $aArr[0] = .UserName $aArr[1] = .UserDomain $aArr[2] = .ComputerName EndWith _ArrayDisplay($aArr,"Example 4 - Works") ; With ObjCreate("Wscript.Network") Local $aArr = [.UserName, .UserDomain, .ComputerName] EndWith _ArrayDisplay($aArr,"Example 5 - Nope") Jos Edited June 15, 2014 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now