PxPlus User Forum

Main Board => Discussions => Programming => Topic started by: Jeffrey Ferreira on November 17, 2022, 05:06:39 PM

Title: Passing a COM Object to a CMD
Post by: Jeffrey Ferreira on November 17, 2022, 05:06:39 PM
Hi List
I was trying to do the following
def object excel_obj,"Excel.Application"

I then created a *cmd\PO to parse object and return values for troubleshooting...
if i do
call "*cmd\PO",excel_obj it works
but if i do

PO EXCEL_OBJ
i get an error 36 ..i don think it sees it as a numeric...i seem to remember something like *VARIANT

can anyone shed any light on this?

thanks
jeff
Title: Re: Passing a COM Object to a CMD
Post by: Stéphane Devouard on November 18, 2022, 06:17:49 AM
Hi Jeffrey

When you do
PO EXCEL_OBJ

ProvideX does a CALL to *cmd/PO and passes it whatever you've type after PO as a string
So in PO you need to do
ENTER args$

And if you check args$ you'll see that it has been loaded with " EXCEL_OBJ"
So there is not much you can do with it as your EXCEL_OBJ variable is available in the calling context only, not in your called *cmd program

However, you may want to check out the *cmd/system/tlb CLI program and borrow its first few lines of code which do basically what you want to achieve

Hope this helps
Title: Re: Passing a COM Object to a CMD
Post by: Jeffrey Ferreira on November 18, 2022, 07:48:55 AM
Hi Stéphane ,
I was hoping there was something that already existed. I should have looked harder. However when i run it it says pvxtlb.exe does not exist?  I'm running version 1710-001 on windows...should it be there?
thanks
jeff
Title: Re: Passing a COM Object to a CMD
Post by: Devon Austen on November 18, 2022, 09:55:59 AM
The pvxtlb.exe is a separate download: https://home.pvxplus.com/downloads/misc/PVXTLB.EXE

For information on it see here:
https://manual.pvxplus.com/PXPLUS/PxPlus%20User%20Guide/External%20Components/PxPlus%20Type%20Library%20Browser/Overview.htm
Title: Re: Passing a COM Object to a CMD
Post by: Jeffrey Ferreira on November 18, 2022, 10:33:25 AM
Thank you - I will try it out.
Title: Re: Passing a COM Object to a CMD
Post by: Mike King on November 20, 2022, 10:32:13 AM
There are a couple of ways to handle this.

One option is at the start of the *cmd program, before issuing the ENTER Var$ to get the arguments, issue an ENTER with no arguments.  This will flip the program from a CALL to a PERFORM allowing you to evaluate the value passed.
Title: Re: Passing a COM Object to a CMD
Post by: Mike King on November 21, 2022, 10:52:31 AM
Just thought I'd take a moment and provide a code example:

Code: [Select]
!
! *cmd/showobj
!
  ENTER ! Make the call a Perform
  LOCAL x$ ! Save X$
  ENTER x$
  x$=STP(x$,2)
  LOCAL objid=EVN(x$)
  PRINT "For object:",objid
  PRINT objid'*
  END

Save the above in *cmd/showobj then you can issue "showobj varname"

Where varname is a variable with the handle to the object.