Jump to content

Recommended Posts

Posted (edited)

The error (?)

I was writing a pretty large script the other day when I came across unexpected errors while accessing structs via the period operator.

1. Create an array containing structs (can be different structs, simplified here):

Local $T = DllStructCreate
Local $aStr[] = [$T("int x;int y"), $T("int x;int y")]
$aStr[0].x = 1
$aStr[0].y = 2
$aStr[1].x = 3
$aStr[1].y = 4

2. Working: Simple access via With:

With $aStr[0]
   .y += .x - $aStr[1].x / .y ^ 2               ; $aStr[1] is a valid reference
EndWith

3. ERROR: Use struct element as Array index, simplified:

With $aStr[0]
   .y += .x - $aStr[.x].x / .y ^ 2
EndWith

produces:

==> Variable subscript badly formatted.:
.y += .x - $aStr[.x].x / .y ^ 2
.y += .x - $aStr[.x].x / .y ^ ^ ERROR

4. ERROR: Struct element as Array index, complex:

With $aStr[0]
   .y += .x + ((Sqrt(Abs($aStr[1].x^2+$aStr[.x].y^2))-$aStr[1].x)/.y)*.y
EndWith

produces:

==> Unbalanced brackets in expression.:
.y += .x + ((Sqrt(Abs($aStr[1].x^2+$aStr[.x].y^2))-$aStr[1].x)/.y)*.y
.y += .x + ((Sqrt(Abs($aStr[1].x^2+$aStr[^ ERROR

5. ERROR: Struct element as Array index, outside of any With:

Function($aStr[$aStr[0].x].y)

Func Function($nP)
   Return Default
EndFunc

produces:

==> Unbalanced brackets in expression.:
Function($aStr[$aStr[0].x].y)
Function($aStr[^ ERROR

 

Crashing SciTe

Now, this is a abstract example of this error. But in my script, AutoIt executed the script, then aborted with an error (not warning). I tried to jump to the error within SciTe using F4. That is when SciTe itself crashed with a memory exception ("SciTe.exe does not respond blah blah..."). This happend every time and I was able to reproduce this on different PCs. I lost the script however. I will try to recreate it ;-)

 

Example

You can download a script for testing. Remove the "#" to test each line.  Download: refer.au3.

Edited by minx

I will answer every single PM, and you are free to ask anything anytime.

Posted

Also strange: The error pointer "^" is always on the wrong character.

I will answer every single PM, and you are free to ask anything anytime.

Posted (edited)

SciTE Lite 3.4.1 (the one included in the latest stable)

Edit: This also happened with SciTE4Au3

Edited by minx

I will answer every single PM, and you are free to ask anything anytime.

Posted

Let me know when you have a way to replicate it so I can have a look.

Jos

​I guess it is not a SciTE problem. I assume AutoIt runs in the memory of SciTE when executed via F5? Then it should be an error in the AutoIt Interpreter (caused by the bug above).

I will answer every single PM, and you are free to ask anything anytime.

Posted

Hello,

try it this way.

With $aStr[0]
   .y += .x - ($aStr[.x]).x / .y ^ 2
EndWith
With $aStr[0]
   .y += .x + ((Sqrt(Abs($aStr[1].x^2+($aStr[.x]).y^2))-$aStr[1].x)/.y)*.y
EndWith
Function($aStr[($aStr[0].x)].y)

 

​This is merely a workaround, not clean code.

I will answer every single PM, and you are free to ask anything anytime.

Posted

Maybe I missing something, but when did dot notation work on DllStructCreate in the stable version?

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

Posted

What's not a clean code here?

With the brackets but only the priority of the operator is changed. This is done in many languages so!

​No it isn't. () in AutoIt is "convert to expression". The value of .x should be directly accessible, the priority is completely irrelevant here :)

I will answer every single PM, and you are free to ask anything anytime.

Posted

​When using With...EndWith, but again I ask, where in the changelog does it say you can do ... $aStr[0].x = 1? Honestly, I believe this to still be an experimental feature, from my limited understanding of course.

 

 

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

Posted

​When using With...EndWith, but again I ask, where in the changelog does it say you can do ... $aStr[0].x = 1? Honestly, I believe this to still be an experimental feature, from my limited understanding of course.

​Hm. It's enabled in the stable, so it should not produce unrelated errors (IMHO). It isn't mentioned in the Help file, but it is there.

I will answer every single PM, and you are free to ask anything anytime.

  • Moderators
Posted

minx,

It's enabled in the stable, so it should not produce unrelated errors (IMHO). It isn't mentioned in the Help file, but it is there.

That is a complete non sequitur. If something is not mentioned in the Help file then it is not even "Experimental" and should not be used under any circumstances - even if it apparently "works" in some cases.  So complaining that there are problems when using it is unlikely to get any response other than the one I have just given.

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

 

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
×
×
  • Create New...