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

2
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

3
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

4
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...)

5
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.

6
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 €

7
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


8
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

9
Programming / Re: Syntax error in IF with string expressions
« on: March 13, 2023, 12:26:07 PM »
I usually use nul(string$) or not(nul(string$))

I usually avoid complex conditions with nested IF ELSE and { }

Even in languages that have fancy IDEs with indentation and code folding, developers recommend using "guards"
ie simple IFs to prematurely exit from a given process or function

I often use
Code: [Select]
for (some condition)
! // do the work
next


Or if there are more conditions to test
Code: [Select]
for (1)
if (some condition) then break
if (some other condition) then break
! // lets do the work
next

Anyway, thanks guys for your input

10
Programming / Syntax error in IF with string expressions
« on: March 13, 2023, 04:28:01 AM »
Hi
My boss found the issues in the attached image while doing some code

I've tried some variations with parentheses to transform variables into values but still getting the error 20

11
Wish List / Re: An updated Eclipse Plugin
« on: January 11, 2023, 11:57:08 AM »
… or a VS Code extension ;)

12
Programming / Re: Apache HTTP Interface
« on: January 07, 2023, 02:26:14 AM »
Hi
Up to 4 years ago, the Apache interface used to be compatible with IIS as well and there were some information about it in the « Running on the web » section of the doc IIRC.
It looks like this information has been moved to the Webster+ docs at
https://manual.pvxplus.com/PXPLUS/Webster/Webster%20Setup.htm#iis_setup
Basically you need to create a CGI handler for the .pxp file extension in IIS, and give all you web-based programs this common extension, and you should be good to go.
Hope this helps

13
Programming / Re: Passing a COM Object to a CMD
« 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

14
Language / *obj/xml issue
« on: October 11, 2022, 03:59:41 AM »
Hi

There is a minor issue in *obj/xml with the find_node() method

Code: [Select]
-}x=new("*obj/xml","<prestashop><products><product><id>1</id></product></product
s></prestashop>")
-}
-}xpath$="prestashop/products/product/id"
-}? x'find_node(xpath$)'value$
1
-}?xpath$
prestashop

I can work around by sending the parameter by value with parentheses or as an expression such as xpath$+""

But I think it should be handled in the method itself by protecting the _tag$ input parameter

TIA

15
Programming / Addressing an object
« on: September 28, 2022, 10:46:08 AM »
Hi

This code returns an error 29 on line 581


Code: [Select]
0580 IF XL[J]=0 THEN XL[J]=NEW("*obj/xml")
0581 XLIG=XL[J]'ADD_NODE("ligne")

I told the boss to change it to :

Code: [Select]
0580 if xl[j]=0 xd=new("*obj/xml"); xl[j]=xd else xd=xl[j]
0581 xlig=xd'add_node("ligne")

And it worked

Looks like this type of syntax
Code: [Select]
array[index]'some_method() While valid, is not supported by the parser or compiler

That being said, we are on a V16 with V15 license, maybe it has been fixed in a more recent version ?

Regards

Pages: [1] 2 3 ... 8