Sign in to follow this  
Followers 0
jaberwacky

Anybody see anything wrong with my syntax?

17 posts in this topic

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
~~^

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

#4 ·  Posted (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_position
Edit: Two "not"'s and the line about the array declaration crossed out because of new found knowledge. Edited by Malkey

Share this post


Link to post
Share on other sites

 

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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

$struct.X, $struct.Y

I don't believe this is "officially" supported.

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#9 ·  Posted (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 by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

You really need to learn some manners and if you can't then go and play somewhere else.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Oho! This is new.

What I "need" isn't for you to say.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

 

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites

#17 ·  Posted (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 by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0