Jump to content

Possible _ArrayUnique bug?


Jfish
 Share

Recommended Posts

I think there may be a bug with _ArrayUnique introduced in 3.3.14 (or it could just be me).  I updated ticket #3078 with the attached files to demonstrate.  If you run test.au3 against the test data file in 3.3.12 it works and you see a unique array from _arrayDisplay.  If you do the same in 3.3.14 the _arrayDisplay view will be empty.

I read the script breaking changes and the updates but I don't think it should have cause this.  Please let me know if I am doing something wrong.

#include <Excel.au3>
#include <Array.au3>

func _openSourceData()
$sourcefile=FileOpenDialog("Please select source file",@ScriptDir,"All (*.*)")
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.")
    else
    ; Create application object
    Local $oAppl = _Excel_Open()
    If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    ; *****************************************************************************
    ; Open an existing workbook and return its object identifier.
    ; *****************************************************************************
    Local $sWorkbook = $sourcefile
    $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook, Default, Default, True)
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example 1", "Error opening '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
        $sourceArray=_Excel_RangeRead($oWorkbook)
        _ArrayDisplay($sourceArray)
        $unique=_ArrayUnique($sourceArray)
        _ArrayDisplay($unique)
    EndIf
EndFunc
_openSourceData()

 

test.au3

testData2.xlsx

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

Is it _ArrayUnique() or Excel? Create a reproducer without the Excel dependency, to isolate whether or not it is in fact Excel that is the issue.

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 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: 22/04/2018

Link to comment
Share on other sites

It's _ArrayUnique.

This section of code is checking the $iBase element of the array, but doesn't take into account if the array is a 1 or 2D array when it does the second line.

If $iIntType = $ARRAYUNIQUE_AUTO Then
        If IsInt($aArray[$iBase]) Then ; <<<<<<<<<<<<<<<<<<<<<<<<
            Switch VarGetType($aArray[$iBase])
                Case "Int32"
                    $iIntType = $ARRAYUNIQUE_FORCE32
                Case "Int64"
                    $iIntType = $ARRAYUNIQUE_FORCE64
            EndSwitch
        Else
            $iIntType = $ARRAYUNIQUE_FORCE32
        EndIf
    EndIf

 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

By the way, you do realise that the bug fix is in an unreleased version of AutoIt, so of course you're still seeing the bug. If you PM me I will send you the function if using v3.3.12.0 isn't possible for now.

Edited 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 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: 22/04/2018

Link to comment
Share on other sites

  • Moderators

Hi,

This has been discussed many times before and was fixed in 3.3.14.2:

; Autocheck of first element
    If $iIntType = $ARRAYUNIQUE_AUTO Then
        Local $vFirstElem = ( ($iDims = 1) ? ($aArray[$iBase]) : ($aArray[$iColumn][$iBase]) )
        If IsInt($vFirstElem) Then
            Switch VarGetType($vFirstElem)
                Case "Int32"
                    $iIntType = $ARRAYUNIQUE_FORCE32
                Case "Int64"
                    $iIntType = $ARRAYUNIQUE_FORCE64
            EndSwitch

        Else
            $iIntType = $ARRAYUNIQUE_FORCE32
        EndIf
    EndIf

M23

Release notes

Edited by Melba23
Added link to release notes

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

 

Link to comment
Share on other sites

I just downloaded the latest stable version yesterday with a fresh install on a new PC.  Scite shows it as 3.3.14.2 but I am still getting error.  Also, I checked the ticket listed on that release note and it said it was closed because it could not be reproduced (unless I read it incorrectly ... very possible).

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

Hi,

This has been discussed many times before and was fixed in 3.3.14.2

I have updated the ticket to reflect this backport, as it's a little misleading.

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 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: 22/04/2018

Link to comment
Share on other sites

  • Moderators

jfish,

Scite shows it as 3.3.14.2 but I am still getting error

Can you post a reproducer with the same error but without the Excel dependency? As it stands there is no way we can test.

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

 

Link to comment
Share on other sites

All:

I modified my reproducer script that is run against the same data file I provided to cover three scenarios using two variations each of _ArrayUnique: (i) read the array from Excel, (ii) create a new array from the Excel array, (iii) write the data to a flat file and read it back as an array.  In the first two examples both failed when _ArrayUnique was run without the optional parameter @Jos suggested that dictates which algorithm to use but it worked when that parameter was set to 4 (as stated above).  The last example, where the data was read from the flat file to create the array worked in both scenarios.  Script:

#include <Excel.au3>
#include <Array.au3>
#include <File.au3>

func _ArrayUniqueIssueSpotter()
$sourcefile=FileOpenDialog("Please select source file",@ScriptDir,"All (*.*)")
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.")
    else
    ; Create application object
    Local $oAppl = _Excel_Open()
    If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    ; *****************************************************************************
    ; Open an existing workbook and return its object identifier.
    ; *****************************************************************************
    Local $sWorkbook = $sourcefile
    $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook, Default, Default, True)
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example 1", "Error opening '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
        $sourceArray=_Excel_RangeRead($oWorkbook)

        ; THIS DOES NOT WORK
        _ArrayDisplay($sourceArray,"original Excel Array")
        $unique=_ArrayUnique($sourceArray,1)
        _ArrayDisplay($unique, "DOESN'T WOKR: Array from Excel")
        ; THIS DOES WORK
        $unique=_ArrayUnique($sourceArray,1,0,0,1,4)
        _ArrayDisplay($unique,"WORKS: array from Excel")

        ;****************************
        ; CREATE NEW ARRAY OF SAME SIZE WITH SAME DATA FROM ORIGINAL
        ;******************************
        local $newArray[UBound($sourceArray)][UBound($sourceArray,2)]
        $textFile=FileOpen(@ScriptDir&"\sampledata.txt",2)
        for $a=0 to UBound($sourceArray)-1
            $newArray[$a][0]=$sourceArray[$a][0]
            $newArray[$a][1]=$sourceArray[$a][1]
            ; WRITE THE DATA TO A FLAT FILE WHILE WE ARE CREATING THE NEW ARRAY
            FileWriteLine($textFile,$sourceArray[$a][0]&','&$sourceArray[$a][1])
        Next
        FileClose($textFile)

        ;****************************
        ; NOW CHECK THE NEW ARRAY WE CREATED FROM THE EXCEL ARRAY
        ;******************************
        _ArrayDisplay($newArray,"Original new array")
        ; THIS DOES NOT WORK
        $uniquenew=_ArrayUnique($newArray,1)
        _ArrayDisplay($uniquenew,"DOESN'T WORK: new array unique")
        ;THIS DOES WORK
        $uniquenew=_ArrayUnique($newArray,1,0,0,1,4)
        _ArrayDisplay($uniquenew,"WORKS: new array unique")

        ; read the data back from the flat file into a new array:
        local $aRetArray
        $flatFileData= _FileReadToArray(@ScriptDir&"\sampledata.txt", $aRetArray,default,',')

        ;****************************
        ; NOW CHECK THE NEW ARRAY WE CREATED FROM THE FLAT FILE
        ;******************************
        ; trim the count in the zero index
        _ArrayDelete($aRetArray,0)
        _ArrayDisplay($aRetArray,"Original flat file array")
        ; THIS DOES WORK
        $uniqueFlat=_ArrayUnique($aRetArray,1)
        _ArrayDisplay($uniqueFlat,"WORKS: new unique array from flat file array")
        ; THIS DOES WORK
        $uniqueFlat=_ArrayUnique($aRetArray,1,0,0,1,4)
        _ArrayDisplay($uniqueFlat,"WORKS: new unique array from flat file array")
    EndIf
EndFunc
_ArrayUniqueIssueSpotter()

 

Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

  • Moderators

Jfish,

Just as well I included all those various algorithm possibilities when I rewrote the function!

It would seem that you have a real mix of content in that array - can you let us know exactly what is included?

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

 

Link to comment
Share on other sites

@Mebla23, I told @Jfish that I can't test as I don't have Excel.

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 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: 22/04/2018

Link to comment
Share on other sites

  • Developers

This is the array created:

1   dog
2   cat
3   monkey
1   dog
2   cat
3   monkey
1   dog
2   cat
3   monkey
1   dog
2   cat
3   monkey
1   dog
2   cat
3   monkey
1   dog
2   cat
3   monkey
1   dog
2   cat
3   monkey
1   dog
2   cat
3   monkey
1   dog
2   cat
3   monkey

So it is pretty strait forward what is done. anything that I can help with to test?

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

  • Developers

I would just add that the issue only seems to manifest when the original array comes from Excel (as far as I can tell).

I saw the same indeed, but haven't done any debugging why the returned array from _Excel_RangeRead($oWorkbook) is different than building the array manually with the data shown.

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

  • Moderators

I do not have Excel either, but Softmaker Office opens the file and I see nothing peculiar within it. It looks as if we need water to take a look - he is the resident Excel expert and I wonder if there is something about the _Excel_RangeRead return which is causing the problem.

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

 

Link to comment
Share on other sites

I looked at _Excel_RangeRead and the function reads the "value" of the range by default which is a variant (as opposed to text).

https://msdn.microsoft.com/en-us/library/office/ff195193.aspx

Here is another piece of weirdness ... I used a variable for the @iIntType algorthim and ran it against all options.  It is only option 0 - the default - that does not workAnd it only does not work with the Excel array.

@Water - any thoughts?

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

  • Developers

I think it is something we need to look at in _ArrayUnique(). This is what is returned by this test script:

#include <Excel.au3>
#include <Array.au3>

_openSourceData()

Func _openSourceData()
    Local $oAppl = _Excel_Open()
    Local $sWorkbook = @ScriptDir & "\testData2.xlsx"
    $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook, Default, Default, True)
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example 1", "Error opening '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    $sourceArray = _Excel_RangeRead($oWorkbook)
    For $x = 0 To UBound($sourceArray,1)-1
        For $y = 0 To 1
            ConsoleWrite($x & "-" & $y & "=" & $sourceArray[$x][$y] & "=>" &VarGetType($sourceArray[$x][$y]) & @CRLF)
            If $y = 0 Then
;~              $sourceArray[$x][$y]=String($sourceArray[$x][$y])
            EndIf
        Next
    Next
    _ArrayDisplay($sourceArray)
    $unique = _ArrayUnique($sourceArray)
    _ArrayDisplay($unique)
    $unique = _ArrayUnique($sourceArray,1)
    _ArrayDisplay($unique)
EndFunc   ;==>_openSourceData

 

The first cell is a Double:

--> Press Ctrl+Alt+END to Restart or Ctrl+Break -or- Ctrl+END to Stop
0-0=1=>Double
0-1=dog=>String
1-0=2=>Double
1-1=cat=>String
2-0=3=>Double
2-1=monkey=>String

This causes the $iIntType to remain 0. is that correct?

When I change it to:

If $iIntType = $ARRAYUNIQUE_AUTO Then
        ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iIntType = ' & $iIntType & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
        Local $vFirstElem = ( ($iDims = 1) ? ($aArray[$iBase]) : ($aArray[$iColumn][$iBase]) )
        If IsInt($vFirstElem) Then
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : IsInt($vFirstElem) = ' & IsInt($vFirstElem) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
            Switch VarGetType($vFirstElem)
                Case "Double"
                    $iIntType = $ARRAYUNIQUE_FORCE32
                Case "Int32"
                    $iIntType = $ARRAYUNIQUE_FORCE32
                Case "Int64"
                    $iIntType = $ARRAYUNIQUE_FORCE64
            EndSwitch
        Else
            $iIntType = $ARRAYUNIQUE_FORCE32

        EndIf
    EndIf

Thing seem to work.

Jos

Edited 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

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