Jump to content

Errors that make no sense... again!


 Share

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>

Example()

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
EndFunc

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)
    EndIf
    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
    Next
    If $iErrorCount > 0 Then Return SetError(4, $iErrorCount, False)
    Return $mReturnMap
EndFunc

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.3.6.0.0   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 (3.3.15.0)  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.
    $mMap[$vKey]
    ~~~~~~~~~~~^
"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.
    $mMap[$vKey]
    ~~~~~~~~~~~^
"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:

0ca0c70b6dec2b2f8eda122f53093b48.png

Thanks in Advance, TD :)

Edited by TheDcoder
Added Spoilers & Image

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Thats easy :) Replace

ElseIf Not IsArray($vKeys)

with

ElseIf Not IsArray($vKeys) Then

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

×
×
  • Create New...