kryton9
07-05-2017, 12:12
I don't understand how DIR_List returns a pointer
and then the LL is able to determine the data, does it
point to a known UDT?
I am trying to make LL's easy to use with my own custom UDT's
so was working on this study code.
'Based on an example from the thinBasic Help
Uses "Console"
Uses "FILE"
Uses "LL"
String currentDir = DIR_GetCurrent
PrintL "Dir Size = " + dirSize currentDir
WaitKey
Function dirSize ( dir As String )
Long index
Long dirListPtr
Long numItems
Long dirSizeTotal
Long params = %FILE_NORMAL Or %FILE_HIDDEN Or %FILE_SYSTEM Or %FILE_ADDPATH
String fileName
dirListPtr = DIR_List ( dir, "*.*", params )
numItems = LL_Count ( dirListPtr )
If numItems > 0 Then
For index = 1 To numItems
fileName = LL_GetItem ( dirListPtr, index )
PrintL fileName
dirSizeTotal += FILE_Size fileName
Next
End If
Return dirSizeTotal
End Function
'[!] <pay attention note: important>
'DIR_List required ()
'LL functions also required ()
9685
and then the LL is able to determine the data, does it
point to a known UDT?
I am trying to make LL's easy to use with my own custom UDT's
so was working on this study code.
'Based on an example from the thinBasic Help
Uses "Console"
Uses "FILE"
Uses "LL"
String currentDir = DIR_GetCurrent
PrintL "Dir Size = " + dirSize currentDir
WaitKey
Function dirSize ( dir As String )
Long index
Long dirListPtr
Long numItems
Long dirSizeTotal
Long params = %FILE_NORMAL Or %FILE_HIDDEN Or %FILE_SYSTEM Or %FILE_ADDPATH
String fileName
dirListPtr = DIR_List ( dir, "*.*", params )
numItems = LL_Count ( dirListPtr )
If numItems > 0 Then
For index = 1 To numItems
fileName = LL_GetItem ( dirListPtr, index )
PrintL fileName
dirSizeTotal += FILE_Size fileName
Next
End If
Return dirSizeTotal
End Function
'[!] <pay attention note: important>
'DIR_List required ()
'LL functions also required ()
9685