PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Passing a COM Object to a CMD  (Read 1020 times)

Jeffrey Ferreira

  • Diamond Member
  • *****
  • Posts: 175
  • I must have taken a wrong turn at Albuquerque.
    • View Profile
Passing a COM Object to a CMD
« 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

Stéphane Devouard

  • Diamond Member
  • *****
  • Posts: 122
  • PxPlus guru with skills in PHP, JS, C#, Java
    • View Profile
    • Stéphane's Web Resume
Re: Passing a COM Object to a CMD
« Reply #1 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
Stéphane Devouard
Portfolio | Work

Jeffrey Ferreira

  • Diamond Member
  • *****
  • Posts: 175
  • I must have taken a wrong turn at Albuquerque.
    • View Profile
Re: Passing a COM Object to a CMD
« Reply #2 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

Devon Austen

  • Administrator
  • Diamond Member
  • *****
  • Posts: 382
  • Don’t Panic
    • View Profile
    • PVX Plus Technologies
Principal Software Engineer for PVX Plus Technologies LTD.

Jeffrey Ferreira

  • Diamond Member
  • *****
  • Posts: 175
  • I must have taken a wrong turn at Albuquerque.
    • View Profile
Re: Passing a COM Object to a CMD
« Reply #4 on: November 18, 2022, 10:33:25 AM »
Thank you - I will try it out.

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Passing a COM Object to a CMD
« Reply #5 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.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Passing a COM Object to a CMD
« Reply #6 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.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com