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
1
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

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

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

Regards

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


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

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

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"))

5
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

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


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

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


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$["client_id"]=clientID$
postdata$["grant_type"]="client_credentials"
postdata$["scopes"]="urn:tr:onesource:auth:api:IndirectTaxDetermination"
postdata$["client_secret"]=clientSecret$
postdata$=DIM(LIST EDIT postdata${all})

8
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
https://manual.pvxplus.com/PXPLUS/Automation%20in%20PxPlus/PxPlus%20COM%20Interface%20Extensions/Overview.htm


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


Hope this helps

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

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

10
Programming / Re: Avalara Tax Integration
« on: July 18, 2023, 04:49:42 AM »
Hi

Not related in any way to the Avalara API interface but may help (or not...)

This is how I request the french postal service API to get all the cities/towns for a given postal code
The service uses a REST API with JSON data payloads - which is a breeze to generate and parse with PxPlus

Code: [Select]
0170 REQUEST$=FN_URL$+"/lines"
0180 REQUEST$+="?q="+STR(CCP:"00000")
0190 REQUEST$+="&select="+CVS("nom_de_la_commune,ligne_5","ascii:url")
0200 REQUEST$+="&size=99"
0210 CALL "*plus/web/request",ERR=*NEXT,REQUEST$,"",RESPONSE$,HEADERS$
0220 IF POS("200"=HEADERS$)=0 THEN ERRMSG$=TBL(TCB(2),"",MSG(ERR)); GOSUB USE_LOCAL
0230 DIM LOAD RESULT${ALL}=RESPONSE$,ERR=PROCESS_END
0240 BUREAUX$=""
0250 CITIES=TRY(NUM(RESULT$["total"]),0),CITY=0
0260 WHILE ++CITY<=CITIES
0270 COMMUNE$="",LIGNE_5$=""
0280 COMMUNE$=RESULT$["results."+STR(CITY)+".nom_de_la_commune"]
0290 LIGNE_5$=RESULT$["results."+STR(CITY)+".ligne_5"]
0300 CHOIX$=COMMUNE$
0310 IF POS(";"+CHOIX$+";"=";"+BUREAUX$)=0 THEN BUREAUX$+=CHOIX$+";"
0320 INFO$=PAD(COMMUNE$,INT(MXC(0)/3)); IF LIGNE_5$<>"" THEN INFO$+=PAD(" ancien nom : "+LIGNE_5$,INT(MXC(0)/3)); INFO$
0320:+=PAD(" --> "+CHOIX$,INT(MXC(0)/3))
0330 IF NOT(CALLED) THEN PRINT PAD(INFO$,MXC(0))
0340 WEND
...
0990 DEF FN_URL$="https://datanova.laposte.fr/data-fair/api/v1/datasets/laposte-hexasmal"


The request is built on statements 170-200
The request is sent using the PxPlus HTTP client on statement 210, getting back the response data and HTTP headers
Statement 210 checks the response status (should be 200 if everything went well)
Statement 230 parses the JSON response into a PxPlus associative array
The response JSON schema is :
Code: [Select]
{
  "total": 2
  "results": [
    { "nom_de_la_commune": "BRUNOY", "ligne5": "" },
    { "nom_de_la_commune": "BOUSSY SAINT ANTOINE", "ligne5": "" }
  ]
}
Which results in the following assoc array :
Code: [Select]
result$["total"]="2"
result$["results.1.nom_de_la_commune"]="BRUNOY"
result$["results.1.ligne5"]=""
result$["results.2.nom_de_la_commune"]="BOUSSY SAINT ANTOINE"
result$["results.2.ligne5"]=""

Making it very easy to iterate and get the required info

Hope this helps

11
Wish List / Re: An updated Eclipse Plugin
« on: June 08, 2023, 10:14:32 AM »
Hi Gord


Long time no talk, hope you're doing well
Would definitely like a VSCode implementation as it is already my editor of choice for almost all non-PVX coding
Depending how such an extension is done, I could even contribute (I think I could still write some decent C# code...)

12
Programming / Re: PxPlus 2023 Projects
« on: May 27, 2023, 01:54:17 AM »
Nevemind, just spotted the little statement in the release notes. My bad. Sorry for the noise.

13
Programming / PxPlus 2023 Projects
« on: May 25, 2023, 06:10:43 AM »
Hi
Up until PxPlus 2022, projects metadata were stored in KEYED files *plus/proj/wkids.dat and *plus/proj/wkseq.dat
A change had been made in recent years to allow those files to be LINK files pointing to another location to be able to retrieve projects when upgrading PxPlus
I understand PxPlus 2023 changed this to a more traditional way with a folder and a dedicated settings file (like package.json for NodeJS projects and composer.json for PHP projects)
This is great. But apparently it means that I have to re-create all the projects I had set up (not so many fortunately), since I copied the two LINK files from my pxp2022/lib/_plus/proj folder to the same location in my pxp2023 installation, and no automatic migration happened, I have only the "default" project in the IDE.
Again, not a big issue, just something that would be useful -- either an automatic process first time the project maintenance is opened, or an additional option to run once in the utility that was previously used to create the LINK files
My 0.02 €

14
Programming / Re: Strange if then else behavior
« on: May 13, 2023, 03:48:19 AM »
After using IF {} ELSE {} for several years
I found it hard to follow especially when having several nested IFs
I started adding remarks to denote the level of nesting such as :
Code: [Select]
if some_condition { ! <-
if nested_condition { ! <--
if yet_another_condition { <---
... some code ...
} ! --->
} ! -->
} ! ->
But it is still hard to follow


I started coding in other languages (C#, PHP, JS) with fancy IDEs that have indentation
But even witht all the bells and whistles, a complicated algorithm is hard to follow
And I have watched numerous coding tutorials where it is recommended to avoid complicated nested if/else structures and use guards instead
i.e.
Do all the tests that prevent the main logic to be processed, and return from the routine/method/functions
Then do the processing
Using Mike's GOSUB technique, that would be :
Code: [Select]
GOSUB Do_Some_Logic
...
Do_Some_Logic:
if some_condition then return
if some_other_condition then return
if yet_another_condition then return
! // now do the logic
return


I also use the simple FOR/NEXT structure A LOT :
Code: [Select]
for (1)

if some_condition then break
if some_other_condition then break
if yet_another_condition then break
! // now do the logic
next


15
Programming / Re: Preview / Viewer Object
« on: April 08, 2023, 03:10:55 AM »
Hi Jeff

Is that what you're looking for ?
Code: [Select]
->preview=new("*viewer/preview")
->? preview'*
AlwaysUseDefaultOpenPath,Banner,Bottom,Caption$,Close(),Collate,Color,Colour,Col
umn,Columns,Copies,DPIPrinter,DPIScreen,DefaultFixedFont$,DefaultFixedFontSize,D
efaultOpenPath$,DefaultOrientation,DefaultOrientation$,DefaultPaperSize,DefaultS
aveAsPath$,Delete(),DisableBanner,DisableDelete,DisablePrint,DisableSaveAs,Disab
leSearch,DisableWatermarks,Event(),FileName$,Find(),FindNext(),FindPrevious(),Fi
rstPage(),GotoPage(),HelpContents$,HelpFile$,HelpIndex$,Icon$,Init(),Language$,L
astPage(),Left,LookAndFeel,MinimumColumns,MinimumRows,NextPage(),Open(),OutputEv
enNumberOfPages,Page,PageGutterHorizontal,PageGutterVertical,Pages,PaginationAt,
PreviousPage(),Print(),Printer$,PrinterDescription$,Process(),Quit(),Range$,RePa
int(),Report,Right,Row,Rows,SaveAs(),SaveAsPDF(),ScaleToFit,ScrollDown(),ScrollL
eft(),ScrollRight(),ScrollUp(),SetCallBack(),SetWindowStateOnCreate,SetWindowSta
teOnFirstPage,SetWindowStateOnSpoolComplete,SetWindowStateOnSpoolStart,Software$
,SuppressAllBlankPages,SuppressBannerInfo,SuppressFirstBlankPage,SuppressPrinter
Selection,SuppressSplashScreen,SuppressStatusBar,SuppressToolBar,SuppressToolTip
s,SuppressWaterMarks,ThemeName$,Top,UsePrinter$,Version$,View,View(),Visible,Wat
erMark,WaterMarkPages,Zoom,Zoom(),ZoomIn(),ZoomOut(),_revision$,

Regards

Pages: [1] 2 3 ... 9