I have exposed COM objects from wsc files via type libraries before. It is a pain in the rear and I refuse to ever do it again, but here are my links for the web pages that I used to figure it out:
These days if I feel the urge to create a COM component, I either slam a door on my head a couple of times or else I do it in a full blown programming language.
Posts: 2174
Score: 32
Joined: 6/29/2006
From: Orange County, California
Status: offline
I can't believe you took the time to put this together. PrimalScript makes it easy to put a WSC together with the necessary info to make it viewable in a typelib browser. I used it to create a WSC with the code you put together. Below is the difference that allows for this up to the point where the <public> <method name="Concat">
I can't believe you took the time to put this together
THis only took about an hour and a half in notepad
quote:
PrimalScript makes it easy to put a WSC together with the necessary info to make it viewable in a typelib browser.....
Thanks for the registration info. I've added. (It doesn't create the tags totally right, but it did 90% of the work)
<?xml version="1.0" ?> <package> <comment> </comment> <component id="JSArray"> <?component error="true" debug="true" ?> <registration progid="JS.Array" classid="{EC189C13-F413-4BBC-AE90-9A2083E5A090}" description="JSArray" version="1.0"> <script language="VBScript"> <![CDATA[ Function Register() Dim TypeLib Set TypeLib = CreateObject("Scriptlet.TypeLib") TypeLib.AddURL "JSArray-v1.WSC" TypeLib.Path = "JSArray-v1WSC.tlb" TypeLib.Doc = "JSArray-v1" TypeLib.Name = "JSArray-v1WSC.tlb" TypeLib.MajorVersion = 1 TypeLib.MinorVersion = 0 TypeLib.Write End Function
Function Unregister()
End Function ]]> </script> </registration>
Now viewable in the object browser, awesome.
The Pop() bug has been fixed thanks to some help from a colleague (russell) at Webdeveloper.com
It should be noted though that Pop() and Shift() don't work the way they do in JScript. In my version these two methods return the remaining array. In JScipt it returns the first or last element and just alters the array without returning it (I didn' see the point of this).
Alright, significant update this time. I translated more functions into vbscript with some help from my JavaScript colleague again (I'll post all the credit when we finally finish)
Heres a quick overview over the new function list (<---Function is complete and passed all bug tests) (<--Function is not working or is bugged)
Concat(Array1,Array2,Array3.......Arrayn) Returns a new array consisting of a combination of two or more arrays. Ex:
Index(Array1,Value,Begin,Strict) Returns the position in the Array of the FIRST element that matches the specified Value. If the argument is not found in array, a value of -1 is returned. Array-The Array being searched Value-What you are looking for in the Array Begin-Where to start looking in the Array Strict-This can be either 0 or 1 0-Match the value only 1-Match value and type Explanation- Within an array, elements can be of different types.For Example 4 is a number, '4' is a string, and [4] is an array itself. You may want to know the difference Ex:
Del(Array1,Index) Deletes an Element in the array and resizes the original array to its new value: Ex:
Insert(Array1,Index,Value) Insert a new value at the Index and automatically resize the array Ex:
LastIndex(Array1,Value,Bottom Limit,Strict) Returns the Last position in the Array of the FIRST element that matches the specified Value. If the argument is not found in array, a value of -1 is returned. Array-The Array being searched Value-What you are looking for in the Array Bottom Limit-Where to start looking in the Array Strict-This can be either 0 or 1 0-Match the value only 1-Match value and type Explanation- Within an array, elements can be of different types.For Example 4 is a number, '4' is a string, and [4] is an array itself. You may want to know the difference: Ex:
Length(Array1) Return the Length of an array Ex:
Pop(Array1) Removes the last element from an array, the original array is altered Ex:
Push(Array1,Value) Adds an Item to the end of an Array. The original array is altered: Ex:
Random(Array1) Return a random element from the array Ex:
Reverse(Array1) Reverses the order of the array Ex:
Replace(Array1,Index,Value) Replace a value at the Index with the new value
Shift(Array1)
Shuffle(Array1)
Slice(Array1,StartI,EndI)
Sort(Array,Type) Returns an Array sorted according to the type: 0-Dictionary Sort (This means that '30' is less than '4' and gets sorted that way. If your array consists entirely of numbers then you probably want to sort numerically instead.) 1-Reverse Dictionary Sort 2-Ascending Numeric Sort 3-Descending Numeric Sort Ex:
Splice(Array1,Start,DelCount,Array2)
Split2(String,Separator) Creates an array from a String using the Separator defined . Unlike the normal Split() function, Split2() will let you split the String using a regular expression or an empty string "" Ex:
Swap(Array1,Index1,Index2) Swap the position of Index1 and Index2 in Array
Undupe(Array1) Removes Duplicates from Array and returns the new array Ex:
UnShift(Array1,Value) Adds Element to the begginning of Array1 and returns the new array Ex:
< Message edited by TNO -- 12/21/2006 11:58:55 PM >
Would someone mind giving me a dummy class on the difference between passing an argument to a VBScript Function ByVal and ByRef? I don;t think I'm doing it entirely correct and am getting improper results on a couple of these
Sub ByRefExample(ByRef strFoo) 'This one will alter the value of the variable passed In strFoo = "Changed in ByRefExample" End Sub
Sub ByValExample(ByVal strFoo) 'This one will not alter the value of the variable passed in strFoo = "Changed in ByValExample" WScript.Echo vbTab & "In the ByValExample Sub, strFoo = " & strFoo End Sub
The output is:
Before calling ByRefExample. strTest = Start After calling ByRefExample. strTest = Changed in ByRefExample Calling ByValExample In the ByValExample Sub, strFoo = Changed in ByValExample After calling ByValExample. strTest = Changed in ByRefExample
I'm very interested in your project. I learned a lot by my first walk thru your code, and I want to put some code behind my feelings. Because I think of you as a programmer interested in speed, I reworked my old Sort benchmark from this forum. I used this as a test if I could get your component to work on my machine - success, no problems at all - you may use it to test and demonstrate the quality and speed of your code.
The benchmark provides for Insertion Sort (thanks ebgreen), Sort via .NET ArrayList (needs Runtime 1.1 or greater) and my first attempt of using JSArray.Sort(). Selecting methods/data samples/sizes shouldn't be difficult for anybody seriously interested in this topic (but feel free to ask).