PxPlus User Forum

Twitter Twitter Twitter

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Stéphane Devouard

Pages: [1] 2 3 ... 9
Language / Re: Easiest way to create an XML file
« on: June 04, 2024, 04:44:40 AM »

Working daily at my job with *obj/xml to handle interfaces with an e-Commerce app API, I haven't been confronted with any memory issue in the last 2 years

*obj/xml represents an XML node, so internally, every single node or subnode of your XML document is an *obj/xml instance
IIRC the powerpoints from 20+ years ago, in PVX OOP, all instances of the same class share the logic (the methods are loaded in memory only once), only the instance data (properties) is distinct.
The actual XML string is created only when you use the 'get_xml$() method

In any case, Mike's logic is the best way to go if you're worried about memory usage

My 0.02€

Nomads / Re: Library Query
« on: May 28, 2024, 10:51:20 AM »

The problem here is the inclusion of TCB(13) in the file name

TCB(13) is not a fixed value throughout your session. It varies depending how deep you are in the CALL stack.
In your main program it is 0.
In a subprogram called / performed from your main program it is 1.
In a sub-subprogram called / performed from your subprogram it is 2.

Doing a PROCESS of a panel or a query is like doing a CALL.
So if you created your temp file in your main program, it was named WKFLT0010.
If you PROCESS a query to read it, that's a CALL, so when the query runtime program tries to resolve the file name, it evaluates to WKFLT0011 which does not exist.

You need to change the way you name your WKFL files if you want to make this work.

Nomads / Re: Library Query
« on: May 28, 2024, 01:13:33 AM »
TCB(13) is the current level in the program call stack
If you create the work file in your main level program, its value will be 0
But PROCESS a panel and it’s value is set to 1 or 2 because basically PROCESS is a call to *winproc
Invoke a query from the panel (which is a call to *winproc which then performs *winqry) and now your TCB(13) is 4 or 5
Not sure why you want to include TCB(13) in the file name, but it will never work as you’ve experienced. If you included this for file name uniqueness, maybe TCB(89) would be a better choice as it is the same whatever level you are in the call stack
Hope this helps

Web Services / Re: Posting a File to a Web Service
« on: May 25, 2024, 01:07:34 PM »

Jeff’s suggestion is only an example, you need to check the documentation of the API you’re trying to interact with and see what is the name of the html form field that this API expects. If filename does not work, maybe it is file_name or xml_file.
Also make sure that the data in the XML file is escaped using either cvs(…, "utf8:xml") if the data may contain utf8 encoded characters, or cvs(…, "ascii:xml") in case the data contains reserved XML chars such as < >


You can spare a call by using the cvs() function
base64_credentials$ = cvs(raw_credentials$, "ascii:base64")

Web Services / Re: Posting a File to a Web Service
« on: May 18, 2024, 03:47:31 AM »

Attached is the PVX helper class I use to upload files to APIs

Use it like this :

Code: [Select]
field_name$="Name of the form field the webservice is waiting for"
file_name$="Name of the file to upload : this will be the value of the form field above"
file_content$="File content"
file_mime_type$="MIME type of the file to upload, application/octet-stream by default"
! // use upload'content_type$ as mime_type in the *plus/web/request
! // use upload'body$() as body in the *plus/web/request

The file_content$ variable should be loaded with a binary read of the file

Code: [Select]
open (hfn,isz=-1) file_name$
file_content$ = rcd(lfo,siz=10000000)

Hope this helps


Here is the code I use on Linux to ungzip content returned by some APIs we're working with :

Code: [Select]
0780 UNGZIP:
0800 !
0810 UNGZIPPED$=""
0820 !
0830 GZFILE$="/tmp/pvx/TEMP."+FID(0)+"."+DTE(0:"YYYYMMDD.%Hz%mz%sz")+".gzip"
0850 IF TCB(2)=1 THEN RETURN ""
0870 CLOSE (LFO)
0880 FOR (GZIPPED$="")
0890 OPEN (HFN,ERR=*BREAK)"<cat "+GZFILE$+"|gzip -d"
0910 CLOSE (LFO)
0930 NEXT
0940 !

Hope this helps

Programming / Re: JSON from Array with numeric and string
« on: March 27, 2024, 12:44:59 PM »
Hi Cedric

Check out the DIM CLASS directive : https://manual.pvxplus.com/PXPLUS/directives/dim_class.htm

Hope this helps

Language / Re: ERROR 302 file not found
« on: March 25, 2024, 04:24:12 PM »

HTTP error 302 is not a file not found error but a redirect status

You should use the *plus/web/request http client instead, which will follow redirections


Nomads / Re: Convert NOMADS file to XML (need IOLIST)
« on: March 14, 2024, 02:20:12 AM »

When using the SVN interface from PxPlus, programs and Nomads libraries are converted to text when you commit changes to the repo. Each library becomes a folder and each Nomads object (panels, queries, file maintenance, menus) is converted to a text file.
The format of the exported file is not XML, it’s more like an INI file format
I believe the conversion program can be called. You’d need to explore the *plus/proj folder to find out.

Hope this helps

Wish List / Re: string interpolation
« on: November 16, 2023, 06:55:57 AM »

String interpolation exists (kinda) in PxPlus :

Code: [Select]
print MSG(="Hello, %1 ! Today is %2, it's %3 now.",name$,dte(0:"%Wl"),dte(0:"%Hz:%mz"))

Nomads / Re: Creating a new instance of an object especially for a Query
« on: November 09, 2023, 02:02:32 AM »
Hi Arno

PxPlus has an interesting concept of LOCAL globals

If you declare
LOCAL %INFO$ in a program

Then %INFO$ will be global in the current stack level and "above"
If there is another similar declaration in a higher stack level, then the current %INFO$ value will be preserved, the new value will replace it, and when dropping to a lower stack level, the preserved value will be restored

Hope this helps

Registration and Setup / Re: PxPlus Help on Win 2022
« on: October 18, 2023, 09:59:21 AM »

Right-click on the .chm file in the PxPlus folder and select Properties
There is a security box at the bottom of the dialog that you may need to check so that Windows does not think the file is malicious

Hope this helps

Web Services / Re: REST problems
« on: September 30, 2023, 03:14:36 AM »

You don't have to build postdata$ if the API server accepts JSON

You can use PxPlus internal conversion of hash tables to JSON
Code: [Select]
postdata$=DIM(LIST EDIT postdata${all})

Language / Re: How to pass a com object string property greater than 32k?
« on: September 21, 2023, 11:20:49 PM »
Hi Ken

You have the pvxextdata[$] extended properties to GET more than 32K of data

Not sure about SETting more than 32K, though...

Hope this helps

Programming / Re: performance of select record
« on: August 28, 2023, 07:16:53 AM »

As it knows all the keys I'm interested in including all conditions it should be much faster than any programmed logic.

This is an incorrect assumption. ProvideX SELECT is *not* SQL SELECT

You are right about SQL SELECT where the SQL engine chooses the best possible path to get to the data based on various criteria including the WHERE clause -- and it will be fast as long as you have indexed the columns on which you're selecting.

ProvideX SELECT is some syntactic sugar which allows you to easily code a file read loop
You can use a file channel or a file name. If you use the latter, the file will be closed after the last NEXT RECORD iteration
However :
- You must select yourself the best KNO to access the data. ProvideX won't do it for you
- If you use a file channel, the SELECT will start the loop at the current cursor position in the file, unless you use the BEGIN clause to specify the first key to read (this is the same as the Cobol START statement)
- Adding a WHERE allows ProvideX to execute the logic inside the SELECT/NEXT RECORD loop for only the records that match the conditions. Basically the IFs are done at the C-level therefore they are faster. If you don't specify a WHERE then the loop will be executed for all the record between the BEGIN (if any) and END (if any) clauses

Hope this helps

Pages: [1] 2 3 ... 9