PxPlus User Forum

Twitter Twitter Twitter

Author Topic: SafeArray from Linux  (Read 874 times)

Peter.Higgins

  • Gold Member
  • ****
  • Posts: 70
    • View Profile
SafeArray from Linux
« on: November 02, 2018, 12:38:35 PM »
Has anyone tried using the dim structure with pxplus to create a safe array on a linux server.  I'd like to bulk transfer to excel without using the clip board.  Just wondering if there was any point in trying this. 

typedef struct tagSAFEARRAY {
  USHORT         cDims;
  USHORT         fFeatures;
  ULONG          cbElements;
  ULONG          cLocks;
  PVOID          pvData;
  SAFEARRAYBOUND rgsabound[1];
} SAFEARRAY, *LPSAFEARRAY;

https://msdn.microsoft.com/en-us/magazine/mt778923.aspx

Mike King

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3368
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: SafeArray from Linux
« Reply #1 on: November 02, 2018, 02:09:41 PM »
Have you tried the PxPlus 2017 Excel object to transfer data or use the OLE interface to update a range in a single command?

Using PxPlus 2018 and the program below it took under 2 seconds to launch Excel and load 1000 rows of 25 columns.

Code: [Select]
  begin
!
  for r=1 to 1000
    for c=1 to 25
    data$+="R"+str(r)+"C"+str(c)+sep
    next c
  next r
!
  strt=tmr(3)
!
  xl=new("*obj/excel" for program)
  xl'CreateWorkBook("")
  xl'write(data$,"A1..Y1000")
  xl'visible=1
!
  print "Load time=",tmr(3)-strt," Seconds"
  escape


Peter.Higgins

  • Gold Member
  • ****
  • Posts: 70
    • View Profile
Re: SafeArray from Linux
« Reply #2 on: November 02, 2018, 03:57:40 PM »
Thanks Mike,

Have had a copy of the OLE safe array logic for years.   Works fine on a windows server. 
I've never been able to successfully use the OLE interface from Linux.  Always get an error too difficult to figure out somewhere.   *obj/excel almost worked.  At the bottom is an error probably tied to the largest windx string size which I am not sure of but 30,000 characters got the same error.
 
010 DEF OBJECT VARIANT,"*VARIANT"
Error #99: Feature not supported.

-}x=new("*obj/excel")
Error #99: Feature not supported
-}

-;/
0010 !
0020 FOR r=1 TO 1000
0030 FOR c=1 TO 25
0040 data$+="R"+STR(r)+"C"+STR(c)+SEP
0050 NEXT c
0055 !
0060 NEXT r
0070 !
0080 strt=TMR(3)
0090 !
0100 xl=NEW("[lcl]*obj/excel")
0110 xl'createworkbook("")
0120 xl'write(data$,"A1:Y1000")
0130 xl'visible=1
0140 !
0150 DROP OBJECT xl
0160 END
-;run
0120 xl'write(data$,"A1:Y1000")
Error #46: Length of string invalid
Current program is <unsaved>, line 120
1;?len(data$)
 565116
1;


Mike King

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3368
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: SafeArray from Linux
« Reply #3 on: November 02, 2018, 04:39:52 PM »
When running across WindX I generally suggest simply create callable program and put it in *plus/wdx/usr then call it passing the data.

For example create *plus/wdx/usr/loadxl with

Code: [Select]
  enter data$,range$,visible
  xl=new("*obj/excel" for window)
  xl'CreateWorkBook("")
  xl'write(data$,range$)
  xl'visible=visible
  end

Then in the program replace lines 100 thru 150 with

Call "[lcl]*plus/wdx/usr/loadxl",data$."A1:Y1000",1

NOTE: This will keep the Excel object up until you close your current window.

Peter.Higgins

  • Gold Member
  • ****
  • Posts: 70
    • View Profile
Re: SafeArray from Linux
« Reply #4 on: November 02, 2018, 05:15:31 PM »
Mike,
Our windx is connected by ssh.
Running lcl mode I was limited to around 4K which took 35 seconds for 1000 lines of just 5 cells.  Didn't bother counting the included array process as inconsequential.   About the same as writing it by cell.  Clip board time is around a second for 500k writes. 

So it makes sense to just send data to an windx object if it can exceed the 4k limit or avoid the marshalling with small packets.