'---Script created on 09-09-2023 12:04:17 by Gary 'Array module Uses "console" 'At it's simplest OOP is just a container of simular functions 'in this module all functions use arrays in some way Type ArrayFunctions Private arrtext as string delimiter as string Public Function _Create(arText as string, delim as string) As Long '--------------------------------------------------- me.arrtext = arText me.delimiter = delim End Function function Chg_ArrayText(arText as string) as string me.arrText = arText end function function Chg_Delimiter(delim as string) as string me.delimiter = delim end function function Text2Array(ByRef arr() As String) dim parsecnt as long,tcnt as long parseCnt = ParseCount(me.arrText,me.delimiter) ReDim arr(parsecnt) As String Parse me.arrtext, arr(),me.delimiter end function Function Array2Text(a() As String) As String Function =Join$(a(),me.delimiter) End Function FUNCTION Array2Clip(a() As String) Dim dd3 As String dd3=Join$(a(),me.delimiter) ClipBoard_SetText(dd3) End FUNCTION function Clip2Array(byref arr() as string) as String dim st As String st = ClipBoard_GetText ReDim arr(ParseCount(st,me.delimiter)) As String Parse st, arr(),me.delimiter end function function RemoveDuplicates (Arr() As string) as long 'fxm from freebasic Dim LB As Integer , j As Integer, UB As Integer UB = Ubound(Arr) LB = LBound(Arr) Do While LB < UB j = LB + 1 Do While j <= UB If Arr(LB) = Arr(j) Then Arr(j) = Arr(UB) UB = UB - 1 Else j = j + 1 End If Loop LB = LB + 1 Loop Redim Preserve Arr(UB) End function function printArray(arr() as string) as string Printl me.Array2Text(arr ) + $crlf end function end type dim tarr(6) as string dim main as string,stxt as string dim newArr(4) as string,nArr(4) as string stxt= "aaaa"+$crlf stxt += "bbbb"+$crlf stxt += "cccc"+$crlf stxt += "dddd"+$crlf Dim arr As ArrayFunctions(stxt,$crlf) 'array module nArr(1)= "1" nArr(2)= "2" nArr(3)= "3" nArr(4)= "4" Print "--------------------------------------------"+$crlf Print "-Print the NewArr()-------------------------"+$crlf 'note: do not put parenthesis after arrayName arr.Text2Array( newArr ) arr.PrintArray( newArr ) stxt= "1111"+$crlf stxt += "2222"+$crlf stxt += "3333"+$crlf stxt += "4444"+$crlf 'next 3 stmts puts new text in oop text string 'puts text in array 'puts it back to text so it can be printed out Print "--------------------------------------------"+$crlf Print "-Print the changed NewArr()-----------------"+$crlf arr.Chg_ArrayText(stxt) : arr.Chg_Delimiter($crlf) arr.Text2Array( newArr ) arr.PrintArray( newArr ) Print "--------------------------------------------"+$crlf Print "-Removes Duplicates from Array tarr()-------"+$crlf tarr(1)= "1" tarr(2)= "2" tarr(3)= "3" tarr(4)= "4" tarr(5)= "4" tarr(6)= "4" arr.RemoveDuplicates(tarr) arr.PrintArray( tarr ) Console_WaitKey
Bookmarks