Jump to content

Errors that make no sense... again!

Recommended Posts


Hello! :), I am getting strange errors while making an example for a function in Maps UDF... Here is my script (AUTOIT BETA REQUIRED!):

#include <StringConstants.au3>


Func Example()
    Local $aArray[5] = ["Foo", "Bar", "Baz", "Qux", "Norf"] ; This is the array to convert
    Local $sKeys = "Primary Place Holder;Secondary Place Holder;Tertiary Place Holder;Quaternary Place Holder;Quinary Place Holder" ; Keys in String Format
    Local $aKeys[5] = ["Primary Place Holder", "Secondary Place Holder", "Tertiary Place Holder", "Quaternary Place Holder", "Quinary Place Holder"] ; Keys in Array Format

    Local $mConvertedMap[]

    $mConvertedMap = _Map_1DArrayToMap($aArray, $sKeys) ; Convert Array To Map with Keys in String format
    ;_Map_Display($mConvertedMap, "Converted Array") ; Display Map

    $mConvertedMap = _Map_1DArrayToMap($aArray, $aKeys) ; Convert Array To Map with Keys in Array format
    ;_Map_Display($mConvertedMap, "Converted Array") ; Display Map

Func _Map_1DArrayToMap(ByRef $aArray, $vKeys, $sDelimiter = ';', $iInitialElement = 0)
    If IsString($vKeys) Then
        $vKeys = StringSplit($vKeys, $sDelimiter, $STR_NOCOUNT)
    ElseIf Not IsArray($vKeys)
        Return SetError(1, 0, False)
    If Not UBound($aArray, 0) = 1 Then Return SetError(2, 0, False)
    Local $iKeyCount = UBound($vKeys)
    Local $iElementCount = UBound($aArray)
    If Not $iKeyCount = ($iElementCount - $iInitialElement) Then Return SetError(3, 0, False)
    Local $mReturnMap[]
    Local $iErrorCount = 0
    For $iElement = $iInitialElement To ($iElementCount - 1) + $iInitialElement
        ; $mReturnMap[$vKeys[$iElement]] = $aArray[$iElement]
        _Map_Append($mReturnMap, $vKeys[$iElement], $aArray[$iElement])
        $iErrorCount += @error
    If $iErrorCount > 0 Then Return SetError(4, $iErrorCount, False)
    Return $mReturnMap

Func _Map_Append(ByRef $mMap, $vKey, $vContents)
    If MapExists($mMap, $vKey) Then Return SetError(1, 0, False)
    $mMap[$vKey] = $vContents
    Return True
EndFunc   ;==>_Map_Append

My SciTE's Output:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /beta /ErrorStdOut /in "C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3" /UserParams    
+>16:16:26 Starting AutoIt3Wrapper v.15.920.938.0 SciTE v.   Keyboard:00004009  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0809)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\TheDcoder\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\TheDcoder\AppData\Local\AutoIt v3\SciTE
>Running AU3Check (  from:C:\Program Files (x86)\AutoIt3\Beta  input:C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(22,28) : error: syntax error
    ElseIf Not IsArray($vKeys)
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(25,37) : error: syntax error
    If Not UBound($aArray, 0) = 1 Then Return
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(26,35) : error: syntax error
    Local $iKeyCount = UBound($vKeys)
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(27,40) : error: syntax error
    Local $iElementCount = UBound($aArray)
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(28,38) : warning: $iElementCount: possibly used before declaration.
    If Not $iKeyCount = ($iElementCount -
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(28,63) : error: syntax error
    If Not $iKeyCount = ($iElementCount - $iInitialElement) Then Return
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(33,44) : warning: $iElement: possibly used before declaration.
        _Map_Append($mReturnMap, $vKeys[$iElement]
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(33,45) : error: syntax error
        _Map_Append($mReturnMap, $vKeys[$iElement],
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(33,65) : error: syntax error
        _Map_Append($mReturnMap, $vKeys[$iElement], $aArray[$iElement])
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(36,27) : error: syntax error
    If $iErrorCount > 0 Then Return
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(42,13) : warning: $vKey: possibly used before declaration.
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(42,27) : warning: $vContents: possibly used before declaration.
    $mMap[$vKey] = $vContents
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(42,27) : error: syntax error
    $mMap[$vKey] = $vContents
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(28,38) : error: $iElementCount: undeclared global variable.
    If Not $iKeyCount = ($iElementCount -
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(33,44) : error: $iElement: undeclared global variable.
        _Map_Append($mReturnMap, $vKeys[$iElement]
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(42,13) : error: $vKey: undeclared global variable.
"C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"(42,27) : error: $vContents: undeclared global variable.
    $mMap[$vKey] = $vContents
C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3 - 13 error(s), 4 warning(s)
!>16:16:26 AU3Check ended. Press F4 to jump to next error.rc:2
+>16:16:26 AutoIt3Wrapper Finished.
>Exit code: 2    Time: 0.8258

SciTE's Screenshot for better error recognition:


Thanks in Advance, TD :)

Edited by TheDcoder
Added Spoilers & Image

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)


My contributions to the AutoIt Community

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) mean to do that to anybody!!!



Share this post

Link to post
Share on other sites

Thats easy :) Replace

ElseIf Not IsArray($vKeys)


ElseIf Not IsArray($vKeys) Then


  • Like 1

My UDFs and Tutorials:


Active Directory (NEW 2018-12-03 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki

ADO - Wiki


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

  • Similar Content

    • kara2004
      By kara2004
      Hi there,
      I have a problem using the latest two betas of au3stripper.exe.
      Compiling my script using V17.224.935.6 works fine, the next two releases (18.624.1847.0 and 18.624.1847.1) show an error:
      !==> *** ERROR: stopping process because include file not found :#include <INCLUDE_FILE.au3> !==> *** Checked these directories : !==> C:\Program Files (x86)\AutoIt3\include\INCLUDE_FILE.au3 !==> SCRIPT_DIR\INCLUDE_FILE.au3 !==> SCRIPT_DIR\INCLUDE_FILE.au3 !>18:42:00 --------------------------------------------------------------- !>18:42:00 Au3Stripper ended with errors, using original scriptfile.rc:999 !>18:42:00 --------------------------------------------------------------- Changing the include line according to the helpfile (using "..." for includes in script dir and <..> for includes in the au3-include-dir won't help!?
    • qsek
      By qsek
      Can somebody try to reproduce this bug?
      It would be helpful to know if this issue appeares on other environments too.
      Sometimes values of certain keys will return empty even if expicitly assigned a value before.
      Map is bigger than ~50 key/values pairs value is being worked with in a Function where a loop is iterating through the Map before retrieving the value there is a isMap/MapKeys/MapAppend/MapRemove check on the Map value. Dim $mMap[] ; Generate random key strings For $i = 0 To 100 $RndKey = "" For $i2 = 0 To 4 $RndKey &= Chr(Random(65,90,1)) Next $mMap[$RndKey] = 999 next ConsoleWrite("-----------1-------------" & @CRLF); Unpredictable blank values MapDisplay1($mMap) ConsoleWrite("-----------2-------------" & @CRLF); ByRef always works MapDisplay2($mMap) ConsoleWrite("-----------3-------------" & @CRLF); not in a function always works For $i In MapKeys($mMap) isMap($mMap[$i]) ConsoleWrite($i&": "&$mMap[$i]&@CRLF) Next Func MapDisplay1( $m_Map ) For $i In MapKeys($m_Map) isMap($m_Map[$i]) ;same problem with isMap($m_Map[$i]), MapKeys($m_Map[$i]), MapAppend/MapRemove but NOT with MapExists($m_Map,$i) ConsoleWrite($i&": "&$m_Map[$i]&@CRLF) Next EndFunc Func MapDisplay2( ByRef $m_Map ) For $i In MapKeys($m_Map) isMap($m_Map[$i]) ConsoleWrite($i&": "&$m_Map[$i]&@CRLF) Next EndFunc  
      The value is not lost or overwritten on the global map, only on the local map inside the function.
    • TheDcoder
      By TheDcoder
      Hello Again! I previously stumbled upon a topic asking for maps datatype's instructions... I too wasn't sure what a map is until I tried it... So I am making this topic to help other newbies (and some oldbies) better understand the Maps datatype of AutoIt! Lets start!
      A Note for Readers
      The maps datatype is still in development and is currently in Alpha Stage (More Risky than Beta) and its unstable, so AutoIt can crash indefinably while using Maps! I can't guarantee if this will be implemented in stable versions, this is a fairly new thing to AutoIt coders & in my honest opinion I don't see any use for it Maps are the best datatype in AutoIt, Very Useful ... Not hurting anyone though .  Also the maps datatype is DISABLED IN STABLE VERSIONS, So you need to install the latest beta version of AutoIt to make maps work . If you find any bugs while using a map, please report it in the Official Bug Tracker
      Introduction To Maps
      Maps are just like arrays, instead they use "keys" to access elements inside them... A key can be either a string or an integer (Other datatypes work too but they are converted to a integer [Equivalent to Int($vKey)] before assignment [Source]). Although Integers don't represent the order of elements in a map unlike in an array...
      Declaring Maps
      Its similar to declaring an Array:
      ; This is the only way to declare a map ; You must have a declarative keyword like Dim/Global/Local before the declaration unless the map is assigned a value from a functions return Local $mMap[] ; Don't insert any numbers or strings it! Simple, Isn't it?
      Using Maps
      Using maps is similar to arrays (again!):
      Local $mMap[] ; Lets declare our map first! ; Adding data to maps is easy... ; This is our key ; | ; v $mMap["Key"] = "Value" ; <--- And our value! ; A key is Case-Sensitive meaning "Key" is not same as "key"! $mMap["key"] = "value" ; Not the same as $mMap["Key"]! ; There are 2 different ways to access an element in a map $mMap["Key"] ; 1st Method $mMap.Key ; 2nd Method  Enumerating Maps
      Its quite easy to enumerate through arrays but what about maps? how can I enumerate through them!?
      #include <MsgBoxConstants.au3> ; Lets create our map first Local $mMap[] ; Lets add some information to the map, feel free to modify & add new elements $mMap["Name"] = "Damon Harris" $mMap["Alias"] = "TheDcoder" $mMap["Gender"] = "Male" $mMap["Age"] = 14 $mMap["Location"] = "India" $aMapKeys = MapKeys($mMap) ; MapKeys function returns all the keys in the format of an array Local $sProfile = "Profile of " & $mMap["Name"] & ':' & @CRLF ; We will use this string later For $vKey In $aMapKeys ; We use this to get the keys in a map :) $sProfile &= @CRLF & $vKey & ': ' & $mMap[$vKey] ; Add some details to the profile string using our map! Next MsgBox($MB_ICONINFORMATION + $MB_OK, "Profile", $sProfile) ; Finally display the profile :) It is easy as always
      Multi-Dimensional Maps
      Now now... I know that you are a little confused that how can an multi-dimensional maps exist... Although I am not 100% sure if its called that but lets continue:

      #include <MsgBoxConstants.au3> ; Multi-Dimensional maps are just maps in a map Local $mMapOfMapsvilla[] ; This map will store an other map Local $mParkMap[] ; This Park map will be inserted in the Mapsvilla's map :P $mMapOfMapsvilla["Map Item 1"] = "Town Hall" $mMapOfMapsvilla["Map Item 2"] = "Police Station" $mMapOfMapsvilla["Map Item 3"] = "Shopping Mall" $mMapOfMapsvilla["Map Item 4"] = "Residential Area" $mMapOfMapsvilla["Map Item 5"] = "Park" $mParkMap["Map Item 1"] = "Cottan Candy Stand" $mParkMap["Map Item 2"] = "Public Toilet" $mParkMap["Map Item 3"] = "Woods" $mMapOfMapsvilla.Park = $mParkMap MsgBox($MB_OK, "Map Location", $mMapOfMapsvilla["Map Item 1"]) ; Will display Town Hall MsgBox($MB_OK, "Map Location", $mMapOfMapsvilla.Park["Map Item 1"]) ; Will display Cottan Candy Stand I am sure its easy for you to understand now
      Frequently Asked Questions (FAQs) & Their answers
      Q #1. Help! My code does not respond to anything (or) I get an "Variable subscript badly formatted" error on the line of declaration...
      A. DONT USE F5 or Go, Instead use Alt + F5 or Tools -> Beta Run in SciTE (Make sure that you have Beta installed)
      Q #2. Why are you using "m" in-front of every map variable?
      A. Best coding Practices: Names of Variables 
      Q #3. What are "Elements" which you mention frequently???
      A. This is a newbie question (I have no intention of insulting you ), so I guess you are new to programming. "Elements" are data slots inside a Map (or an Array), you can imagine elements as individual variable which are stored in a Map. You can access them using "keys", Please refer to "Introduction to Maps" section at the starting of this post
      Q #4. Are Maps faster than Arrays?
      A. You need to understand that Maps have different purpose than Arrays. Maps are designed to store data dynamically (like storing information for certain controlIDs of GUI) and Arrays are designed to store data in a order (for instance, Storing every character of a string in an element for easy access). If you still want to know then if Maps are faster, then the answer is maybe... Maps are *supposed* (I am not sure ) to be faster in addition of elements (while Arrays are painfully slow while adding or removing elements). Here (Post #24) is a benchmark (Thanks kealper! )
      More FAQs coming soon! Feel free to ask a question in the mean while
    • TheDcoder
      By TheDcoder
      Hello! I was wonder if it OK for me to use datatypes other than strings & integers... I tested it and it works! But the help file states: (Beta Helpfile -> AutoIt -> Language Reference -> Variables)
      So yeah, will I able to continue using other datatypes normally even in the future releases of AutoIt?
      Thanks in Advance! TD
    • TheDcoder
      By TheDcoder
      Hello Everyone!
      I made a UDF for the new Maps Datatype, I tried to follow Best Coding Practices & UDF-Specs while making this. Please note that this UDF is in very early stages. A thanks to @boththose for ideas on functions (like _Maps_IniToMap).
      If you have any suggestions, improvements, complaints, feature requests etc. Please don't hold back anything which can help improve this UDF! I will continue to develop this UDF as long as the Official AutoIt Dev Team adapts it (or makes another version of this UDF) .

      Enjoy! TD