Microsoft Script Control 1.0.apl

Discussion forum about all things Team Developer 5.x and 6.x
igor1234
Germany
Posts: 1
Joined: 06 Jul 2018, 13:18
Location: Germany

Microsoft Script Control 1.0.apl

Post by igor1234 » 19 Jul 2018, 08:03

Dear Gupta developers,
is it possible in Class MSScriptControl_IScriptControl the method "Run" to change, in order it returns parameters from script ByRef?
I have done already some changes, because native method "Run" works with SafeArray not properly and passes no parameters to script at all. I have substitute the SafeArray with array of variant variables (Variant: vaArguments[*]) and it works good.
The Function is:

Parameters
String: ProcedureName
Variant: Parameters[*]
Variant: returnValue

Local Variables
Boolean: tmpret
Number: nArrUbound
Number: nIndex
String: sArgOut

Actions
Call __ObjectPushString(ProcedureName)

Set nIndex = 0
Call SalArrayGetUpperBound( Parameters, 1, nArrUbound )
While nIndex <= nArrUbound
Call __ObjectPushVariantByRef(Parameters[nIndex])
Set nIndex = nIndex + 1
Set tmpret = __ObjectInvoke("Run", INVOKE_FUNCTION)
Call __ObjectPopVariant(-1, returnValue)

Set nIndex = 0
While nIndex <= nArrUbound
Call __ObjectPopVariantByRef(nIndex + 1, Parameters[nIndex])
Set nIndex = nIndex + 1
Call __ObjectFlushArgs()
Return tmpret

It receive only the script function returned value (returnValue). But all changes of parameters made in script are not received by Gupta. Can I fix it?

Thankfull,
Igor Itkin

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 1088
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Microsoft Script Control 1.0.apl

Post by Dave Rabelink » 22 Jul 2018, 19:24

I spend some time to play with this and tried several different aproaches.
But unfortunately did not get it working.

On the net I find several similar questions on this, so it seems a general issue.

When you are in charge of the VB script yourself, an solution is to let each VB function set global variables as "return" values.
With the Eval method you can get the values of globals.

Not a very clean solution, but at least can get values back.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 1088
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Microsoft Script Control 1.0.apl

Post by Dave Rabelink » 25 Jul 2018, 06:43

You can find a sample here which shows how to get global script variables back to TD.

http://samples.tdcommunity.net/index.ph ... alVars.zip

As example, here a VBScript

Code: Select all

Class Dog
   Public Name
   Public Color
   Public Breed
End Class

Dim MyGlobalArray( ) 

Function MyFunction( )

	Set myDog = New Dog

	myDog.Name = "Rover"
	myDog.Color = "Brown"
	myDog.Breed = "Beagle"	

	redim MyGlobalArray(4)

	MyGlobalArray(0) = "This is a text"
	MyGlobalArray(1) = 12345
	MyGlobalArray(2) = Date()
	Set MyGlobalArray(3) = myDog

	MyFunction = True
End Function
It uses a global array named MyGlobalArray.
The function MyFunction places the data which should be passed back into the global array.

At TD side, after calling the function, the global array is fetched using Eval command.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests