Alaska Software Inc. - Re: Runshell with Array
Username: Password:
AuthorTopic: Re: Runshell with Array
M.B. BaijuRunshell with Array
on Fri, 29 Jun 2018 08:23:21 +0200
Hello All,

Is there any option can I pass an array with runshell? 
If it is not there then how can I save an array(The array mentioned 
has strings, objects, integers etc.) in the file and restore it.

Please provide me some sample codes.

M.B.BAIJU
Claudio Driussi Re: Runshell with Array
on Fri, 29 Jun 2018 09:07:15 +0200
Il 29/06/2018 08:23, M.B. Baiju ha scritto:

AFAIK

> Is there any option can I pass an array with runshell?

No, with runshell you can call only executables with
command line parameters, your data nust be saved on files.

> If it is not there then how can I save an array(The array mentioned
> has strings, objects, integers etc.) in the file and restore it.

Yes, with var3char() function, but it can handle only simple data,
not objects because they are stored in array by reference.

To inspect object ivars you can use the
::classDescribe( CLASS_DESCR_MEMBERS ) method, search the
documentation.

I advise to convert the data you need to a json file using
the class provided by Pablo Botella and then save to file.

Json is a standard for data communication, so you can handle
it with many languages.

Best regards.

Claudio
Peter AlderliestenRe: Runshell with Array
on Fri, 29 Jun 2018 09:24:30 +0200
Claudio,

> I advise to convert the data you need to a json file using
> the class provided by Pablo Botella 

... or use the Xbase++ function Var2json()

Peter
Claudio Driussi Re: Runshell with Array
on Fri, 29 Jun 2018 09:52:59 +0200
Il 29/06/2018 09:24, Peter Alderliesten ha scritto:
> Claudio,
> 
>> I advise to convert the data you need to a json file using
>> the class provided by Pablo Botella
> 
> ... or use the Xbase++ function Var2json()

from 2.0?
professional?

I have to start migration from 1.9, but in 2.0
foundation I can't see Var2json() function.

Claudio

> 
> Peter
>
Jonathan LeemingRe: Runshell with Array
on Fri, 29 Jun 2018 12:28:03 -0600
On 6/29/2018 1:52 AM, Claudio Driussi wrote:
> Il 29/06/2018 09:24, Peter Alderliesten ha scritto:
>> Claudio,
>>
>>> I advise to convert the data you need to a json file using
>>> the class provided by Pablo Botella
>>
>> ... or use the Xbase++ function Var2json()
> 
> from 2.0?
> professional?
> 
> I have to start migration from 1.9, but in 2.0
> foundation I can't see Var2json() function.
> 
> Claudio
> 
>>
>> Peter
>>
> 
Hi Claudio,

The Var2Json() / Json2Var() are recently added functions to Xbase++ 2.0 
(ver 951 release May 30, 2018) and are included in the foundation edition.

Regards... Jonathan

jonathan.leeming@the-family-centre.com
Edmonton, Alberta, Canada
M.B. BaijuRe: Runshell with Array
on Fri, 29 Jun 2018 12:45:18 +0200
M.B. Baiju wrote in message
news:69701ca8$45c2d053$44859@news.alaska-software.com...
>Hello All,
>
>Is there any option can I pass an array with runshell? 
>If it is not there then how can I save an array(The array mentioned 
>has strings, objects, integers etc.) in the file and restore it.
>
>Please provide me some sample codes.
>
>M.B.BAIJU


Hello All,

Please help me with this JSON Snippet. (XB2.NET)

**********************************
mfile:={}
_mfile := xbJSON():new()  
aadd(mfile,{800,'CASH INVOICE',odlg})
_mfile:AddVar("mfile",mfile)
*************************************

This array has Integer, string and object.
I need to save this JSON table and retrieve the same array.
I am stuck-up with this snippet. Could you help me to write code? 

M.B.BAIJU
Claudio Driussi Re: Runshell with Array
on Fri, 29 Jun 2018 16:16:13 +0200
Il 29/06/2018 12:45, M.B. Baiju ha scritto:

> Please help me with this JSON Snippet. (XB2.NET)
> 
> **********************************
> mfile:={}
> _mfile := xbJSON():new()
> aadd(mfile,{800,'CASH INVOICE',odlg})
> _mfile:AddVar("mfile",mfile)
> *************************************

I don't know about XB2.NET, but you can't freeze
and unfreeze objects. The odlg object is a binary
object stored in memory and you can't recreate
the memory situation loading it from file.

The json format is a text format, so you need to
convert binary data into simple variables and then
store to a json.

You can use the :classDescribe() method (see
documentation) to read and save ivars of object.
But if your goal is to store the state of an
invoice you must write save and load methods
to store your own data.

Sorry, there are no simplified methods.

Regards.

> This array has Integer, string and object.
> I need to save this JSON table and retrieve the same array.
> I am stuck-up with this snippet. Could you help me to write code?
> 
> M.B.BAIJU
>
Carlos a Beling Re: Runshell with Array
on Fri, 29 Jun 2018 11:45:54 -0300
Hello.
Good morning.
Please take a look in Var2Bin() and MemoWrit(), MemoRead() and 
Bin2Var(). Could they help you?

Fraternally
Beling

Em 29/06/2018 11:16, Claudio Driussi escreveu:
> Il 29/06/2018 12:45, M.B. Baiju ha scritto:
>
>> Please help me with this JSON Snippet. (XB2.NET)
>>
>> **********************************
>> mfile:={}
>> _mfile := xbJSON():new()
>> aadd(mfile,{800,'CASH INVOICE',odlg})
>> _mfile:AddVar("mfile",mfile)
>> *************************************
>
> I don't know about XB2.NET, but you can't freeze
> and unfreeze objects. The odlg object is a binary
> object stored in memory and you can't recreate
> the memory situation loading it from file.
>
> The json format is a text format, so you need to
> convert binary data into simple variables and then
> store to a json.
>
> You can use the :classDescribe() method (see
> documentation) to read and save ivars of object.
> But if your goal is to store the state of an
> invoice you must write save and load methods
> to store your own data.
>
> Sorry, there are no simplified methods.
>
> Regards.
>
>> This array has Integer, string and object.
>> I need to save this JSON table and retrieve the same array.
>> I am stuck-up with this snippet. Could you help me to write code?
>>
>> M.B.BAIJU
>>
>
Edgar Borger Re: Runshell with Array
on Tue, 03 Jul 2018 09:57:38 -0300
you can use a simple SAVE command....

aXxx := { ..... }
SAVE all like aXxx to file

Regards,
Edgar




Em 29/06/2018 03:23, M.B. Baiju escreveu:
> Hello All,
> 
> Is there any option can I pass an array with runshell?
> If it is not there then how can I save an array(The array mentioned
> has strings, objects, integers etc.) in the file and restore it.
> 
> Please provide me some sample codes.
> 
> M.B.BAIJU
> 


Edgar Borger
Softsupply Informatica Ltda.
Rua Alagoas, 48
Sao Paulo, SP
01242-000
Tel   : (5511) 3159-1997
Email : softsupply@terra.com.br
Boris BorzicRe: Runshell with Array
on Wed, 04 Jul 2018 15:10:42 +0200
M.B. Baiju wrote in news:69701ca8$45c2d053$44859@news.alaska-software.com:

> Is there any option can I pass an array with runshell? 
> If it is not there then how can I save an array(The array mentioned 
> has strings, objects, integers etc.) in the file and restore it.

 save data
aData := {"hello", 1.23, date(), {||MsgBox("Testing..."}, {"SubArray"}}
SaveSession( aData, "MYDATA.BIN")

 later, you can restore it
aData := RestoreSession("MYDATA.BIN")


 generic functions:

function SaveSession( aData, cFileName )
   Return xbSaveToFile( var2bin(aData), cFileName, .f. )

function RestoreSession( cFileName )
   Local cBin, bErr, xRet

   if FExists(cFileName, "-D-S+H")
      cBin := MemoRead( cFileName )
   endif

   if ! Empty( cBin )
      bErr := ErrorBlock( {|x|break(x)})
      begin sequence
         xRet := bin2var(cBin)
      recover
          add your code to handle error in case of corrupt/invalid file
      endsequence
      ErrorBlock(bErr)
   endif
   Return xRet

Best regards,
Boris Borzic

http://xb2.net
http://sqlexpress.net
industrial strength Xbase++ development tools