Jump to content

_ArrayDisplay $sArrayRange = no data or Variable subscript badly formatted.:


 Share

Recommended Posts

 

ArrayDisplay ( Const ByRef $avArray [, $sTitle = "ArrayDisplay" [, $sArrayRange = "" [, $iFlags = 0 [, $vUser_Separator = Default [, $sHeader = Default [, $iMax_ColWidth = Default [, $iAlt_Color = Default [, $hUser_Function = ""]]]]]]]] )
The $sArrayRange parameter syntax is as follows:

    "7" - Show rows 0-7 with all columns

    "7:" - Show rows 7-end with all columns

    "|7" - Show all rows with columns 0-7

    "|7:" - Show all rows with columns 7-end

    "7|7" - Show rows 0-7 with columns 0-7

    "5:7" - Show rows 5-7 with all columns

    "|5:7" - Show all rows with columns 5-7

    "7|5:7" - Show rows 0-7 with columns 5-7

    "5:7|7" - Show rows 5-7 with columns 0-7

    "5:7|5:7" - Show rows 5-7 with columns 5-7

 >Running:(3.3.10.2):

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=ArrayDisplayTest.exe
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>

Local $List[10]
$List[0] = "JPM"
$List[1] = "Holger"
$List[2] = "Jon"
$List[3] = "Larry"
$List[4] = "Jeremy"
$List[5] = "Valik"
$List[6] = "Cyberslug"
$List[7] = "Nutster"
$List[8] = "JdeB"
$List[9] = "Tylo"


_ArrayDisplay($List, "Test of _ArrayDisplay", "") ; 10 rows, all data
_ArrayDisplay($List, "Test of _ArrayDisplay", "7") ; 8 rows, no data
_ArrayDisplay($List, "Test of _ArrayDisplay", "7:") ; 3 rows, no data
_ArrayDisplay($List, "Test of _ArrayDisplay", "|7") ; 10 rows, no data
;_ArrayDisplay($List,"Test of _ArrayDisplay",  "|7:"  ) ;  ==> Variable subscript badly formatted.:
_ArrayDisplay($List, "Test of _ArrayDisplay", "7|7") ; 8 rows, no data
_ArrayDisplay($List, "Test of _ArrayDisplay", "5:7") ; 3 rows, no data
;_ArrayDisplay($List,"Test of _ArrayDisplay",  "|5:7" ) ; ==> Variable subscript badly formatted.:
;_ArrayDisplay($List,"Test of _ArrayDisplay", "7|5:7" ) ; ==> Variable subscript badly formatted.:
_ArrayDisplay($List, "Test of _ArrayDisplay", "5:7|7") ; 3 rows, no data
;_ArrayDisplay($List,"Test of _ArrayDisplay", "5:7|5:7" ) ;  ==> Variable subscript badly formatted.:
Link to comment
Share on other sites

  • Moderators

TechCoder,

The same old story - fix one thing and break something else. :(

This modified version works for me - please test it and let me know if it does for you. Comments from others welcome too:

<snip>

If everyone is happy then I will change the UDF for the next Beta release. :)

M23

Edited by Melba23
Beta code removed

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

The mod works for me.

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

That fixed that issue - now, I get all the data (yeah).

As an 'addition', I did the following mod;

Func _ArrayDisplayNoExit(Const ByRef $avArray, $sTitle = Default, $sArray_Range = Default, $iFlags = Default, $vUser_Separator = Default, $sHeader = Default, $iMax_ColWidth = Default, $iAlt_Color = Default, $hUser_Func = Default,$bPublic = FALSE)

;****************  insert this at the bottom of the Create buttons section ~ line 280
 
    If $bPublic Then
        GUICtrlSetState($cData_Label,$GUI_hide)
        GUICtrlSetState($cUser_Func,$GUI_hide)
        GUICtrlSetState($cExit_Script,$GUI_hide)
    EndIf

This allows me to use this function to display information to the public - more like the old function.

I was using (and prefer the look of) GUICtrlCreateList, however, in  larger searches, it is extremely slow to display (with 30,000+ records, GUICtrlCreateList takes over 13 minutes).  Using _ArrayDisplay, showing the same data is around 15 seconds, however, it is not desirable to have the User Function and Exit Script buttons showing, thus, the above small mod (I considered also shrinking the size of the GUI window, though felt the empty space was not 'bad' enough to add that).  

Another thing I found is that the splash dialog does not work in the current (nor mod above) version.  The problem is that, in my scenario (1D array), $iSubItem_End and $iSubItem_Start are both 0 and in the current version

If $iVerbose And ($iItem_End - $iItem_Start) * ($iSubItem_End - $iSubItem_Start) > 10000 Then

will ALWAYS result in 0

#include <Array.au3>
Global $aTestArray[20001]
For $i = 0 To 20000
    $aTestArray[$i] = 1
Next
_ArrayDisplay($aTestArray, "Splash Test for > 10000 records", "", 8)

checking values (put this in just before the "Display splash dialog if required" section

ConsoleWrite("$iItem_End is " & $iItem_End & @lf & "$iItem_Start is " & $iItem_Start & @lf & "$iSubItem_End is " & $iSubItem_End & @lf & "$iSubItem_Start is " & $iSubItem_Start & @lf)

shows

 

$iItem_End is 20000

$iItem_Start is 0
$iSubItem_End is 0
$iSubItem_Start is 0
 

 

However, changing this section (~ line 194 of UDF) clears it up (may not be the best way, but it works for me - I did not test 2D arrays);

; Display splash dialog if required
        ; mod by TechCoder to avoid multiplying by 0 on 1D array
    Local $iSubItem_Total
    If $iSubItem_End > 0 Then
        $iSubItem_Total = ($iSubItem_End - $iSubItem_Start)
    Else
        $iSubItem_Total = 1 ; avoid multiplying by 0
    EndIf
    If $iVerbose And ($iItem_End - $iItem_Start) * $iSubItem_Total > 10000 Then
        SplashTextOn("ArrayDisplay", "Preparing display" & @CRLF & @CRLF & "Please be patient", 300, 100)
    EndIf

 

The same old story - fix one thing and break something else.  :(

Those who have never felt the sting of this whip have never coded! :bonk:

 

EDIT: Fixed Display splash mod - it would have broken things too!  ;)

Edited by TechCoder
Link to comment
Share on other sites

  • Moderators

TechCoder,

Glad the fix works - thanks for pointing it out. :thumbsup:

The next Beta release will have an additional flag for the $iFlags parameter to hide all the buttons if required, so that is already covered. I used an older version to debug rapidly this morning which is why it did not appear in the code above. ;)

I will look into the splash code (and your suggested solution) this afternoon if my better half gives me the time - stand by for an update as and when. :)

M23

Edit:

Given the earlier fix to the display ranges, the splash fix is actually very simple - just add 1 to each of the ranges. ;)

Try this Beta version - including the no buttons code. You need the Beta to run it: :)

<snip>

Edited by Melba23
Beta code removed

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

The next Beta release will have an additional flag for the $iFlags parameter to hide all the buttons if required, so that is already covered.

Note that I'm not looking to hide ALL the buttons, as, in my scenario, I am showing the array (a list of 'exceptions' in my case) and the user may want to save it off, print it, etc. so they can work with it bit-by-bit later (I considered just opening Notepad, though the Array looks nicer)

I only want to hide the User Function and Exit Script buttons - the 'Copy' ones, in my case, have value (i.e., please consider the mod for $iFlags to have a couple more options - though I totally understand and agree that it is impossible to 'option' everything - I think that perhaps one to show/not the Exit Script button and {somehow - automatically or matching to the Exit one?} not showing the Function button if there is no function programmed)

Thanks for the kudos and for taking the suggestions under consideration.

Link to comment
Share on other sites

  • Moderators

TechCoder,

How about this? 32 hides all buttons; 16 leaves the "Copy" buttons - "User Func" button only displayed if needed: :huh:

<snip>

And did you see change concerning the splash code? Look for the <<<<<<<<<<<<<< line. ;)

M23

Edited by Melba23
Beta code removed

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

How about this - 32 hides all buttons; 16 leaves the "Copy" buttons? :huh:

I think that works great - though I would still, personally, prefer 

; current line
If Not IsFunc($hUser_Func) Then GUICtrlSetState($cUser_Func, $_ARRAYCONSTANT_GUI_DISABLE)

; new line (or equivalent)
If Not IsFunc($hUser_Func) Then GUICtrlSetState($cUser_Func, $GUI_HIDE)

Reasoning;

1. If it is a coder looking at the display, they already know they can put in a function if they want to, and having a button they can't push does nothing for them anyway.

2. If it is a 'public' view where a coder allows the Exit Script button (in the new version), the user also does not need a button they can't push that has wording they don't understand and/or doesn't relate to their situation (causes frustration and Tech Support questions...).

3. I don't like having buttons I can't change wording or functionality of (simply, 'redundant') being on screen (or, is that obvious???)  ;)

 

And did you see my edit above concerning the splash code?  ;)

Yeah, that works better than mine (not surprised as you understand that code inside/out) - I tested both versions against all numbers 'around' 10,000, using various start digits, etc. - your code worked, mine missed 'sometimes'.......

Link to comment
Share on other sites

  • Moderators

TechCoder,

Have you run the edited code above? I think not because now the "User Func" button only appears if there is a user function passed. ;)

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 knew there was something else I wanted to say in that post - I don't have the BETA software (not exactly sure how to run it separately/differently than released stuff) and am running behind on a schedule right now - so, no, I did not run that directly.  Thought I looked through it well enough and didn't see that a non-function won't display - sorry, missed that.

Seems all the bases are covered on this one - thanks again.

Link to comment
Share on other sites

  • Moderators

TechCoder,

You can download the Beta from here - just install it along with the current release, it does not conflict. if you use the full SciTE4AutoIt3 package (download from here) you then get additional menu options to choose either release or Beta to run/compile. ;)

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

  • Moderators

Hi,

If anyone would be kind enough to test, here is the current Beta version of this function with a couple of example scripts:

<snip>

As always, happy to receive any comments. :)

M23

 

Edited by Melba23
Beta code removed

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

  • Moderators

Hi,

I spent some time while the forum was down polishing the code - if anyone wants to test the new UDF, here it is with an example:

 

M23

Edited by Melba23

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 look forward to testing it - in fact, I, too, was playing around a bit during the 'outage'.....  see what you think about these ideas (and, sorry if they are already done and I haven't seen them - I wanted to d/l the other day, but......).

mod for Array.au3  _ArrayDelete - add support for both types of arrays
 
; #FUNCTION# ====================================================================================================================
; Author ........: Cephas <cephas at clergy dot net>
; Modified.......: Jos van der Zande <jdeb at autoitscript dot com> - array passed ByRef
; Modified.......: TechCoder - $iArrayType to support both Array types
;                  $iArrayType = 0 - where $avArray[0] = contains the first file (default) (data starts at position 0)
;                  $iArrayType = 1 - where $avArray[0] contains the number of files (data starts at position 1)
;                  $iArrayType = 2 - auto-determine which type ('best guess' when $avArray[0] = UBound($avArray))
;                  @error = 5 for non-valid $iArrayType
; ===============================================================================================================================
Func _ArrayDelete_Mod(ByRef $avArray, $iElement,$iArrayType = 0)
If Not IsArray($avArray) Then Return SetError(1, 0, 0)
If Not $iArrayType = 0 and Not $iArrayType = 1 and not $iArrayType = 2 Then Return SetError(5, 0, 0)
Local $iUBound = UBound($avArray, 1) - 1
; Bounds checking
If $iElement < 0 Then $iElement = 0
If $iElement > $iUBound Then $iElement = $iUBound

; Move items after $iElement up by 1
Switch UBound($avArray, 0)
Case 1
For $i = $iElement To $iUBound - 1
$avArray[$i] = $avArray[$i + 1]
Next
ReDim $avArray[$iUBound]
Case 2
Local $iSubMax = UBound($avArray, 2) - 1
For $i = $iElement To $iUBound - 1
For $j = 0 To $iSubMax
$avArray[$i][$j] = $avArray[$i + 1][$j]
Next
Next
ReDim $avArray[$iUBound][$iSubMax + 1]
Case Else
Return SetError(3, 0, 0)
EndSwitch

; Mod [0] if needed (for number in [0] type Arrays)
Switch $iArrayType
Case 0
; do nothing
Case 1
$avArray[0] = $iUBound
Case 2
If $avArray[0] = $iUBound + 1 Then
$avArray[0] = $iUBound
EndIf
EndSwitch

Return $iUBound
EndFunc   ;==>_ArrayDelete_Mod

Also, I did a bit of mod on the Sound UDF (we can move this to another thread if you like)

mod to Sound.au3

 
Added ability to return REMAINING time in _SoundPos
 
; #FUNCTION# ====================================================================================================================
; Author ........: RazerM, Melba23
; Modified.......: $iMode 3/4 by TechCoder (3 = milliseconds remaining, 4 = hh:mm:ss remaining)
; ===============================================================================================================================
Func _SoundPos($aSndID, $iMode = 1)
;validate $iMode
If $iMode <> 1 And $iMode <> 2  And $iMode <> 3  And $iMode <> 4 Then Return SetError(1, 0, 0)
If Not __SoundChkSndID($aSndID) Then Return SetError(3, 0, 0) ; invalid Sound ID or file name

;tell mci to use time in milliseconds
__SoundMciSendString("set " & $aSndID[0] & " time format miliseconds")
;receive position of sound
Local $iSndPosMs = Number(__SoundMciSendString("status " & $aSndID[0] & " position", 255))
If $aSndID[1] <> 0 Then
$iSndPosMs -= $aSndID[2]
EndIf

If $iMode = 3 or $iMode = 4 Then
$iSndPosMs = _SoundLength($aSndID,2) - $iSndPosMs
EndIf

If $iMode = 2 Or $iMode = 4 Then Return $iSndPosMs

;$iMode = 1 (hh:mm:ss)

;modify data and assign to variables
Local $iSndPosMin, $iSndPosHour, $iSndPosSecs
__SoundTicksToTime($iSndPosMs, $iSndPosHour, $iSndPosMin, $iSndPosSecs)

;assign formatted data to $sSndPosFormat
Local $sSndPosHMS = StringFormat("%02i:%02i:%02i", $iSndPosHour, $iSndPosMin, $iSndPosSecs)

;return correct variable
Return $sSndPosHMS
EndFunc   ;==>_SoundPos

Made things a lot simpler in my music player to just return the timer other than having to calculate it again.

I'm working on another project that I got started on during the 'down' and once I finish that I will be getting into the Beta world - only so many hours in a day.......

Link to comment
Share on other sites

  • Moderators

TechCoder,

The next Beta will already have 2D support for most array functions - it was discussed at length here. ;)

I am not a fan of the change to Sound - the calculation is trivial and I see no point in complicating the UDF unnecessarily. :)

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

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