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 - Mike Hatfield

Pages: 1 2 [3] 4 5
31
Programming / JSON files
« on: August 22, 2019, 11:45:24 PM »
Hi All,

When I create JSON files from PxPlus each element terminates with comma+0A.
I note that most JASON files we process from other sources are a continuous stream of data with only a comma between elements.
If I parse the PxPlus file at https://jsonformatter.org/ is validates OK.

Is this correct for PxPlus or should I be doing something to eliminate the 0A ?

SMPRICE_JSON:
CLEAR SMPRICEJSON${ALL}
LET SMPRICEJSON$["Price Date"]=""
LET SMPRICEJSON$["Products.1.Inventory_SKU"]=""
LET SMPRICEJSON$["Products.1.List_Price"]=""

LET SMPRICEJSON$["Price Date"]=DYMD$
FOR I=1 TO 5
READ RECORD (ICM1)ICM1$
LET SMPRICEJSON$["Products."+STR(I)+".SKU"]=ICM1.STOCK_CODE$
LET SMPRICEJSON$["Products."+STR(I)+".Price"]=STR(ICM1.PRICES[1])
NEXT I
LET SMPRICE$=DIM(LIST EDIT SMPRICEJSON${ALL})
LET JSONFILE$="/hit/temp/czapijson.json";
       ERASE JSONFILE$,ERR=*PROCEED;
       SERIAL JSONFILE$;
       OPEN (HFN,ISZ=LEN(SMPRICE$))JSONFILE$;
       WRITE RECORD (LFO)SMPRICE$;
       CLOSE (LFO)

Thanks

32
Programming / Re: Writing CSV files
« on: July 03, 2019, 01:06:00 AM »
Hi Allen,

I thought that was true but wasn't sure.
The file will be imported to Magento 2.x and I wanted to be certain.
Thanks

BTW I just discovered *obj/excel
This is so easy to use, HOWEVER, how do you make it work in WindX where the file you are working with is on the NTHOST server and you are on a workstation that has Excel installed?
 

33
Programming / Writing CSV files
« on: July 02, 2019, 11:06:27 PM »
Hi all

I have to read a csv file, update the 6th column and write the record out again.
I know I could do this with a call to Excel but I can't remember how to do it. I think it would also be very slow.
So, instead I'm reading the input CSV, updating the 6th column and writing it out to a new CSV file.
This is great except the new file has quotes around each column.
How do I write the record without the quotes?

Thanks

00015  DIM CSVREC$[1:7]
00016  IOLIST CSVREC${ALL}:[STR(",")]
00021  OPEN (2)"/HIT/TEMP/CUSTOMER.CSV"
00022  LET CUSTOMEROUT$="/HIT/TEMP/CUSTOMEROUT.CSV"
00023  ERASE CUSTOMEROUT$,ERR=*NEXT
00024  SERIAL CUSTOMEROUT$
00025  OPEN LOCK (3)CUSTOMEROUT$
00030  READ (2,END=0500)IOL=0016
00032  CSVREC$[6]=123456"
00034  WRITE (3)IOL=0016

This becomes
name@gmail.com,base,default,David,Chard,,

this
"name@gmail.com","base","default","David","Chard","123456","",


34
Programming / Re: How to remove a file from an FTP server using Curl
« on: June 11, 2019, 04:51:22 AM »
This worked!
-O or -o is needed depending on whether you want to download to other than the current folder

curl -k -ssl --user username@servername.com.au:password -o \hit\somefolder\Magento\Orders\filename.txt ftp://ftp.servername.com.au/public_html/Future/Texts/ -Q "-DELE filename.txt"

I had to be patient though.
It appeared the file wasn't deleting whilst monitoring the ftp server with Filezilla.
It just takes a while to refresh.


35
Programming / Re: How to remove a file from an FTP server using Curl
« on: June 10, 2019, 11:05:40 AM »
Removing the space certainly made a difference.
It now produces a directory listing on the command window but doesn't delete anything.
That's because the ftp url ends with /Texts/ which generates a listing.
So it seems the -Q onwards was ignored.
As you say, time to consult with curl support.
Thanks for trying.

36
Programming / Re: How to remove a file from an FTP server using Curl
« on: June 07, 2019, 08:19:04 PM »
Hi Devon,

I thought it was going to work but sadly not....
The CURL command seems to be accepted but it just hangs and eventually it times out

curl -k --ssl --user username@servername.com.au:password ftp://ftp.servername.com.au/public_html/Future/Texts/ -Q " -DELE filename.txt"

curl: (28) Timeout was reached

I don't think its the directory (0755) file permissions (0744) because curl didn't complain

37
Programming / Re: How to remove a file from an FTP server using Curl
« on: June 07, 2019, 12:14:58 AM »
Hi Devon,

I tried your suggestion

F:\HIT\TEMP\FTPFILES>curl -k --ssl -Q -DELE ftp://ftp.servername.com.au/public_html/Future/Texts/filename.txt --user username@servername.com.au:password

This is what came back

052C10398880632B4914768747600603C351BF179135309830EE638478376AFA
curl: (21) QUOT string not accepted: DELE


21 FTP quote error. A quote command returned error from the server.

38
Programming / How to remove a file from an FTP server using Curl
« on: June 05, 2019, 08:34:11 PM »
Hi All,

We have written our code to access a Magento FTP Server using CURL to download orders from a folder in json format.
To avoid processing the same orders I need to remove the file from the Magento FTP server as we process it.
That remove command structure is eluding me.
Has anyone removed a file from an FTP Server?
Thanks

39
Web Services / Re: Curl Syntax
« on: May 23, 2019, 06:14:09 PM »
Guys

Thanks for the input.
I had worked out to download the folder contents and then parse it.
I had read about the -o but didn't realise you could specify the path.
So the bit I was missing was the local path.
Thanks.

40
Web Services / Curl Syntax
« on: May 22, 2019, 09:50:00 PM »
I am trying to specifiy the folder to download a file using Curl FTP
It uses the current folder by default.
I have trawled all the online doco but I cant find the syntax to specify the local destination.

LET MPROGRAM$="""\hit\pvx\curl.exe""",MDESTINATION$="ftp://ftp.hatfields.com.au/public_html/Future/Texts/"+TT$,MUSER$=%NW_WEB_USER$+ \
             ":"+%NW_WEB_PASSWORD$

LET SS$=MPROGRAM$+" -k --ssl -O """+MDESTINATION$+""" --user """+MUSER$+"""       "
INVOKE WAIT SS$

The above becomes:


"\hit\pvx\curl.exe" -k --ssl -O "ftp://ftp.domain.com.au/public_html/Future/Texts/mytestfile.txt" --user "username:password"

1. What is the syntax to specify the destination on the local computer?
I assume it's possible because *web/ftp can do it.
Unfortunately *web/ftp won't work with the new certificate requirements on ftp server. You always get an error.
I've had that discussion before, hence using Curl. The -k and --ssl parameters overcome the certificate issue.

2. Is there a syntax to specify all eg   *.txt files on the ftp server to download.
Again I can't find that either.
I did find ranges eg   [100-200].txt but that won't work in my case because the files names could be random.
I have resorted to retrieving a file ( ?.txt ) from the ftp server folder and parsing that for individual files.
 
Thanks

41
Programming / CLEAR vs CLEAR Composite string
« on: May 15, 2019, 05:47:28 AM »
I know what CLEAR does to the program space.
I think the documentation is a bit ambiguous for CLEAR composite string
I can't see any difference in the two forms.
I interpreted CLEAR composite String to ONLY clear the Composite string but it CLEARS the stack as well

CLEAR
CLEAR MORDER${all}
Both clear the for/next/gosub stack
Is this correct?
If so, what is the point of having a separate format 2?

42
Programming / Re: Reading/parsing JSON data
« on: May 15, 2019, 03:51:17 AM »
Hi Thomas,
I wrote a loop as you described and it will loop for as long as the upper range you give it without error.
You comment is what I thought.
I guess if the field is null as opposed to blank or 0 then its at the end.
Thanks

43
Programming / Re: Reading/parsing JSON data
« on: May 15, 2019, 02:52:49 AM »
I just worked out most of this.....I make a mistake
I defined the JSON in the program as MORDER$["Order ID"]=""  etc....
then B$=DIM(LIST EDIT MORDER${all})

DIM LOAD MORDER${all}... should have been DIM LOAD B${all}...
Now
PRINT b$["Order ID"] returns 000000034

My remaining question is how to loop through the Products
There is no field containing the number of product lines EG ["Product lines"]

What would be the correct syntax to loop through the products given that any indeterminate loop will generate an error?

44
Programming / Reading/parsing JSON data
« on: May 15, 2019, 02:12:35 AM »
This is the  JSON Data file supplied

 "Order ID": "000000034",
  "Grand Total": "6",
  "Sub Total": "5.45",
  "Shipping Method": "flatrate_flatrate",
  "Shipping Description": "Order below FIS value - freight to be advised",
  "Payment Method": "Bank Transfer Payment",
  "Billing Details": {
    "City": "Springfield Lakes",
    "Street": "Brisbane",
    "Post Code": "4064",
    "Telephone": "123456789",
    "RegionCode": "Queensland"
  },
  "Shipping Details": {
    "Shipping City": "Springfield Lakes",
    "Shipping Street": "Brisbane",
    "Shipping Post Code": "4064",
    "Shipping Telephone": "123456789",
    "Shipping RegionCode": "Queensland"
  },
  "Customer Details": {
    "First Name": "Test",
    "Last Name": "Maybray",
    "Email": "test234@maybray.com",
    "IP": "144.130.97.53",
    "ID": "412"
  },
  "Products": [
    {
      "ID": "",
      "Name": "9\" x 7\" CLEAR BOOK COVER WITH COLOURED RETURNS - PACK OF 5 - BC97",
      "Type": "simple",
      "Qty": "1",
      "Price": "1.95"
    },
    {
      "ID": "",
      "Name": "SCRAPBOOK COVER - CLEAR - PACK OF 5 - SBC4934",
      "Type": "simple",
      "Qty": "1",
      "Price": "3.5"
    }
  ]
}

My Code snippet below with json as read from file.
What am I doing wrong? How do I access the fields?
My task is to parse the file and create the order in the PxPlus application order file.

  OPEN (HFN,ISZ=10240)"/hit/temp/000000034.json"
  READ RECORD (LFO,ERR=*NEXT)TEMPJSONORDER$;
  LET JSONORDER$+=TEMPJSONORDER$;
  GOTO *SAME
 !
  ESCAPE !
  DIM LOAD MORDER${ALL}=JSONORDER$
 !
  PRINT MORDER$["Order ID"]
 ! This  returns nothing at all



1}? jsonorder$
{"Order ID":"000000034","Grand Total":"6","Sub Total":"5.45","Shipping Method":"
flatrate_flatrate","Shipping Description":"Order below FIS value - freight to be
 advised","Payment Method":"Bank Transfer Payment","Billing Details":{"City":"Sp
ringfield Lakes","Street":"Brisbane","Post Code":"4064","Telephone":"123456789",
"RegionCode":"Queensland"},"Shipping Details":{"Shipping City":"Springfield Lake
s","Shipping Street":"Brisbane","Shipping Post Code":"4064","Shipping Telephone"
:"123456789","Shipping RegionCode":"Queensland"},"Customer Details":{"First Name
":"Test","Last Name":"Maybray","Email":"test234@maybray.com","IP":"144.130.97.53
","ID":"412"},"Products":[{"ID":"","Name":"9\" x 7\" CLEAR BOOK COVER WITH COLOU
RED RETURNS - PACK OF 5 - BC97","Type":"simple","Qty":"1","Price":"1.95"},{"ID":
"","Name":"SCRAPBOOK COVER - CLEAR - PACK OF 5 - SBC4934","Type":"simple","Qty":
"1","Price":"3.5"}]}
1}

1}? morder${all}
00000003465.45flatrate_flatrateOrder below FIS value - freight to be advisedBank
 Transfer PaymentSpringfield LakesBrisbane4064123456789QueenslandSpringfield Lak
esBrisbane4064123456789QueenslandTestMaybraytest234@maybray.com144.130.97.534129
" x 7" CLEAR BOOK COVER WITH COLOURED RETURNS - PACK OF 5 - BC97simple11.95SCRAP
BOOK COVER - CLEAR - PACK OF 5 - SBC4934simple13.5
1}

45
Thin Client/WindX / Re: NTHOST Service on a Windows 10 PC
« on: May 13, 2019, 09:43:11 PM »
Hi Mike K,

I'm not sure how they set up the service.
Their network support did it.
The support are also a dotnet shop so I suspect they have written a small utility to install/uninstall services.

Pages: 1 2 [3] 4 5