Page 2 of 3

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

Posted: Tue Mar 29, 2022 3:01 am
by Tom
No, the Chilkat library is available as an ActiveX component, and that can be (easily!) used from Xbase++. You can use the FoxPro samples, they only need few adaptions.

Code: Select all

FUNCTION UseChilkat()
LOCAL o := CreateObject('Chilkat_9_5_0.Global')
o:UnlockBundle('MyUnlockCodeOrTestText')
IF o:UnlockStatus # 2
  MsgBox('Chilkat not avialable')
  RETURN .F.
ENDIF

* go on and use components

RETURN .T.

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

Posted: Tue Mar 29, 2022 10:36 pm
by Diego Euri Almanzar
Hello Tom

Excellent, many thanks.

Regan Cawkwell informs me that a free version of the Chilkat library may appear. So far, what I've researched costs $300. Do you have any idea of ​​a free version?

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

Posted: Wed Mar 30, 2022 12:18 am
by unixkd
The Chilkat has ActiveX version that can be used very easily in Xbase++. I use a lot of their free components and it is fun.

Joe

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

Posted: Wed Mar 30, 2022 12:26 am
by skiman
Hi,

Some of them are free.
Go to https://www.chilkatsoft.com/refdoc/activex.asp for a list of all the classes.
When you hover above a class, you get a tooltip with the information if it is free or not.

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

Posted: Wed Mar 30, 2022 12:44 am
by unixkd
In addition foxpro is Xbase so the sample code can be translated to Xbase++ very easily e.g.

FOXPRO SAMPLE CODE
===================

Function StockQuote()
LOCAL loRest
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL lnSuccess
LOCAL lcResponseJson

* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

loRest = CreateObject('Chilkat_9_5_0.Rest')

* Connect to the REST server.
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("www.alphavantage.co",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
CANCEL
ENDIF

* Get a stock quote:
* Sending GET request to https://www.alphavantage.co/query?funct ... my_api_key
lnSuccess = loRest.AddQueryParam("function","TIME_SERIES_DAILY")
lnSuccess = loRest.AddQueryParam("symbol","AAPL")
lnSuccess = loRest.AddQueryParam("apikey","my_api_key")
lcResponseJson = loRest.FullRequestNoBody("GET","/query")
IF (loRest.LastMethodSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
CANCEL
ENDIF
Return

XBASE++ TRANSLATION SAMPLE CODE
===============================

Function StockQuote()
LOCAL loRest
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL lnSuccess
LOCAL lcResponseJson

* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

loRest := CreateObject('Chilkat_9_5_0.Rest')

* Connect to the REST server.
lnBTls := 1
lnPort := 443
lnBAutoReconnect = 1
lnSuccess = loRest:Connect("www.alphavantage.co",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1)
? loRest:LastErrorText
RELEASE loRest
CANCEL
ENDIF

* Get a stock quote:
* Sending GET request to https://www.alphavantage.co/query?funct ... my_api_key
lnSuccess := loRest:AddQueryParam("function","TIME_SERIES_DAILY")
lnSuccess := loRest:AddQueryParam("symbol","AAPL")
lnSuccess := loRest:AddQueryParam("apikey","my_api_key")
lcResponseJson := loRest:FullRequestNoBody("GET","/query")
IF (loRest:LastMethodSuccess <> 1)
? loRest:LastErrorText
RELEASE loRest
CANCEL
ENDIF
Return


Joe

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

Posted: Wed Mar 30, 2022 6:02 am
by rdonnay
I would very much like to help with this but I am bogged down in a big project with a deliverable expected on April 9.

I am working a lot with JSON on this project and expect to have more tools for eXpress++ customer in a few weeks.

What would help me is if XbpHtmlViewer() would support JSON formatting when viewing it in the ActiveX web browser.
Both Edge and Chrome support this, but the ActiveX browser does not.

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

Posted: Wed Mar 30, 2022 6:25 am
by Tom
Both Edge and Chrome support this, but the ActiveX browser does not.
I heard rumours that Alaska is working on a replacement for the IE control in XbpHtmlViewer using the Chromium browser/framework.

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

Posted: Wed Mar 30, 2022 6:36 am
by rdonnay
That would be a welcome addition to Xbase++.

Working with Json is actually a dream come true, even when not using Javascript.
Var2Json() and Json2Var() are really the future of my development projects.
It is the best multipart/form response for debugging I have ever seen, even though it is considered light-weight.
Much better than XML.
It works for everything I have thrown at it, except I have to use Edge or Chrome to format it for proper viewing.
I want to add support in WTF to view, properly formatted, Json objects.

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

Posted: Sun Apr 03, 2022 3:35 am
by Diego Euri Almanzar
Thanks, Tom, unix, skiman, and rdonnay.

I have learned a lot from all your texts.

Now, maybe I didn't understand correctly, but as explained by RDONNAY it is preferable to use the Xbase++ and Express++ tools for handling JSON.

I know ActiveX is easy to use, but I prefer to use native tools. I repeat, I think RDONNAY prefers the use of native tools, I think for RDONNAY it supports the use of JSON in the XBASE++ environment

If I misunderstood, please correct me.

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

Posted: Sun Apr 03, 2022 7:22 am
by rdonnay
I know ActiveX is easy to use, but I prefer to use native tools.
I prefer to use native tools also, this is why I have very little usage of third-party tools in eXpress++.

However, there is 1 exception: RmChart.
This is a FREE ActiveX OCX that provides exceptional graphing capability and has always worked perfectly under all Windows and Xbase++ releases.

DCRMCHART is very useful in many of my customer applications.

I am going to make 1 more exception: Chilkat JSON.
I use this only for formatting JSON code to make it more readable in a text editor or in the DCHMTLVIEWER.
This is also a free ActiveX object.
I will be adding support to eXpress++ for viewing DataObjects in JSON format in the debugger (WTF).
If Chilkat JSON is installed, it will also display properly formatted JSON.