Login | |
|
 |
RE: Array Expansion - 12/21/2006 9:38:26 AM
|
|
 |
|
| |
TNO
Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
Ok experts I need your opinion. Would you prefer that a new Array be built with each function or the original Array altered? For example: myArray=Array(1,2,3,4,5) JS.Push(myArray,6) so that myArray now equals Array(1,2,3,4,5,6) OR myArray=Array(1,2,3,4,5) myArray2=JS.Push(myArray,6) so that myArray2 now equals Array(1,2,3,4,5,6) and myArray now equals Array(1,2,3,4,5)?
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
 |
RE: Array Expansion - 12/21/2006 10:34:31 AM
|
|
 |
|
| |
dm_4ever
Posts: 2432
Score: 38
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
quote:
TNO Would you prefer that a new Array be built with each function or the original Array altered? I would go with the altered, but that's just me. Then again, I suppose as long as the arrays are returned in a consistent (whether a new array or altered) maner it would be best.
< Message edited by dm_4ever -- 12/22/2006 12:53:21 AM >
_____________________________
dm_4ever My philosophy: K.I.S.S - Keep It Simple Stupid Read Me: http://www.visualbasicscript.com/m_24727/tm.htm Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Array Expansion - 12/21/2006 9:16:32 PM
|
|
 |
|
| |
TNO
Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
  Insert() bug fixed
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
 |
RE: Array Expansion - 12/22/2006 12:10:40 AM
|
|
 |
|
| |
TNO
Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
Heres the status thus far: <---Function is complete and passed all bug tests) ( <--Function is incomplete or bugged) Concat(Array1,Array2,Array3.......Arrayn) (Returns a new array) Index(Array1,Value,Begin,Strict) (Returns a value) Del(Array1,Index) (Alters Original Array) LastIndex(Array1,Value,Bottom Limit,Strict) (Returns a value) Length(Array1) (Returns a value) Pop(Array1) (Returns Last element value and alters original Array) Push(Array1,Value) (Alters original Array and returns new length value) Random(Array1) (Returns a value) Reverse(Array1) (Alters Original Array) Replace(Array1,Index,Value) (Alters Original Array) Shift(Array1) (Alters Original Array, returns a value) Shuffle(Array1) (Alters Original Array) Slice(Array1,StartI,EndI) (Returns a new Array) Sort(Array,Type) (Alters Original Array) Splice(Array1,Start,DelCount,Array2) (Alters Original Array) Split2(String,Separator) (Returns a new array) Swap(Array1,Index1,Index2) (Alters Original Array) Undupe(Array1) (Alters Original Array) UnShift(Array1,Value) (Alters Original Array)
< Message edited by TNO -- 12/23/2006 6:34:14 AM >
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
 |
RE: Array Expansion - 12/22/2006 4:54:08 AM
|
|
 |
|
| |
ebgreen
Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
|
I admit that I haven't looked at the code, but I would like to advise caution regarding ever using Split() and Join(). I would go the potentially slower but safer route of rebuilding the array by hand.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Array Expansion - 12/22/2006 6:00:27 AM
|
|
 |
|
| |
TNO
Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
quote:
I admit that I haven't looked at the code, but I would like to advise caution regarding ever using Split() and Join(). I would go the potentially slower but safer route of rebuilding the array by hand. Thanks for the advice, but I've worked with translating the code between the two languages enough to know the what pitfalls there are. Passing the workload into JScript and sending the results back save alot of time and codespace. (JScript arrays aren't true arrays but hashtables). because of this fact there is a little overhead that I don't like (myArray.toArray()) <--Turning a standard array into JScript's hashtable array. From this point the JScript speed demon does what it needs to do and turns the result into a string (a string separated by the BackSpace character) as weird as that sounds I figured it was the smartest method since the odds of having ASCII code 8 in your array is extremely unlikely at best. The string is then passed back into VBSscript to get split back into a True Array to be used by the rest of your program. I do agree that its not always the best idea, and that sometimes its faster to just build a VBScript remake instead of translating back and forth, and in those cases (when you look at the code) you'll notice that a number of the functions are 100% vbs. dm_4ever, thats an excellent start at JS, but as a hint for the future, you can save yourself alot of typing like this: function aShift(a) { a = a.toArray(); a.shift(); return a.join('\b') } is the same as function aShift(a){ return a.toArray().shift().join('\b') } Takes a little to get used to I admit, but once the basic premise is there you can pick it up almost as easy as vbs I'm going to play with it a bit more with all your suggestions, maybe even get lucky and get it all working in a couple hours.
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
 |
RE: Array Expansion - 12/22/2006 6:23:21 AM
|
|
 |
|
| |
ebgreen
Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
|
It took me about 10 seconds to think of an instance where using SPlit() and Join() with Chr(8) would be a problem. If I want to put an undo feature into an HTA that works like your standard editor undo, then I woould need to essentially log keystrokes for an editable field. THe easiest way would be to just push them onto an array and pop them off for the undo. I backspace a lot when I type so I would need to have Chr(8)s in the array.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Array Expansion - 12/22/2006 6:31:21 AM
|
|
 |
|
| |
TNO
Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
Good example. How about ASCII 7 (Bell)?
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
 |
RE: Array Expansion - 12/22/2006 6:43:10 AM
|
|
 |
|
| |
TNO
Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
Alright then...what delimiter do you suggest we use as the 90% solution?
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
 |
RE: Array Expansion - 12/22/2006 7:18:05 AM
|
|
 |
|
| |
TNO
Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
quote:
I would like to point out that I am in no way attempting to denigrate the great work that you have done on this. Just looking for pitfalls. Its a group effort. this is exactly the kind of criticism I'm looking for. I've changed the delimiter to Bell, and uploaded the file.
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
 |
RE: Array Expansion - 12/23/2006 6:45:16 AM
|
|
 |
|
| |
TNO
Posts: 1064
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
|
Merry Christmas, the array Expansion is complete Should we add and upgrade the Dictionary object too while we're at it? Got anything you'd like to add or change about it?
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
|
|