#213165 - 2018-01-27 04:11 PM
Re: functions and time of execution
Loc: New Jersey
1 - RTFM!! Fall asleep with your face in the pages! When I first started using Kix, I created a spreadsheet (Excel 97 ??) with the function/command name, a very short description, and a field that indicated it's potential usefulness. Knowing what's available is half the challenge (as you have seen). I took this one step further just this week, creating a script to index all the functions in my library to create a handy reference table.
2 - Review the function library (www.kixtart.org/udf) to see them all indexed. As much as we all say to treat them like "black boxes", they can provide a wealth of brain food - interesting ideas and concepts for often unrelated functionality.
3 - Keep sharing and asking questions - we've all learned from each other, collaborated on projects, and the result has been some pretty awesome code.
4 - Join our Golf tournaments - we could use some more people on the course! Several of these have directly resulted in useful UDFs that I use quite often in my production code. After more than 20 years of writing Kix scripts, I'm amazed that I always learn something new in the Golf rounds.
Of course, the quality of your posts show that you probably already know most of this stuff, but a reminder never hurts. Plus, others less familiar would not be hurt by reading this and following such guidelines.
This is the best place to post such questions as it's the forum that Ruud always scans for issues and ideas. Several functions that have been suggested have made it into Kix over the years, Replace being one of the newest that I can recall.
Here's some answers to your questions above.
ReDim Preserve $Var
This won't work because there are two separate arrays referenced by this - an "array of arrays". If you think about this, the inner array doesn't need to be a fixed size. I can create, for example, an outer array of family members, the inner array containing a list of their children. My mom had 5 brothers and sisters, so her outer array would have 6 elements (0-5). She had 2 kids, 2 of her sisters had 3 kids, one sister had 4 kids, her brother had 2, and her other brother had none. Thus, the inner arrays would each be different lengths.
If you want to redefine both array sets because your inner arrays are all a consistent size, you'd need to process the inner arrays first, then the outer array.
If I used this logic on my mom's family array, she'd lose 4 family members, and those would be limited to listing 4 kids. It should be trivial to adapt this to a function.
For $X = 0 to UBound($Var)
$aTmp = $Var[$X] ; Load inner array into a temp
ReDim Preserve $aTmp ; resize temp array, preserving data
$Var[$X] = $aTmp ; return resized data to outer array
ReDim Preserve $Var ; resize outer array
SPLIT? Sure - the Split(string, null) returning an array of chars would be pretty cool, but here's a quick alternative. For this kind of thing to make it into a Kix update, it has to either be fairly trivial to implement, have a fair demand for the functionality, and overall, must not break scripts developed on older versions. This might have potential.
So - keep posting your work - your collection library has got my creative juices flowing! And, keep asking questions and making suggestions.. It's really great to see some new blood in the group!
$A = TxtToAry('KIX')
Join($A, '-') ?
; Convert a text string to an array of characters
; Glenn Barnas
For $_P = 1 to Len($_S)
ReDim Preserve $TxtToAry[$_P - 1]
$TxtToAry[$_P - 1] = SubStr($_S, $_P, 1)
a Rocket Scientist!
Moderator: Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
and 307 anonymous users online.