An interesting aspect of using boxed arrays for verb execution is that it is
easy to change the line order, excute the same line over and over and test
out different things without a rewrite.
V=:'try.';'catch. ''something is wrong''';'end.'

        0       1                                             2

V=:V,'a=.y';'smoutput ''hejsan svejsan''';'a+55';'a*x'
           3             4                                     5        6


V=:V,'a=. >:a';'+''8'''
             7            8


(3 : (3 7  7 7 7{ V) ) 5
(3 : (0 3 7  7 7 7 8 1 2 { V) ) 5
2 (4 : (0 3 7  7 7 7 6 8 1 2 { V) ) 5
2 (4 : (0 3 7  7 7 7 6  1 2 { V) ) 5

   (3 : (3 7  7 7 7{ V) ) 5
9

   (3 : (0 3 7  7 7 7 8 1 2 { V) ) 5
something is wrong

   2 (4 : (0 3 7  7 7 7 6 8 1 2 { V) ) 5
something is wrong

   2 (4 : (0 3 7  7 7 7 6  1 2 { V) ) 5
18


2009/3/23 Björn Helgason <[email protected]>

>    V=:'a=.y';'smoutput ''hejsan svejsan''';'a+55'
>    V
> +----+-------------------------+----+
> |a=.y|smoutput 'hejsan svejsan'|a+55|
> +----+-------------------------+----+
>    (3 : V) 2 3 4 5 6
> hejsan svejsan
> 57 58 59 60 61
>    V=:'a=.y';'smoutput ''hejsan svejsan''';'a+55';'a*x'
>    34 (4 : V) 2 3 4 5 6
> hejsan svejsan
> 68 102 136 170 204
>
>
> 2009/3/23 Alex Rufon <[email protected]>
>
>> Hi Bjorn,
>>
>> I tried the following:
>>   temp=. '{. ~.'
>>   (3 : temp) 1 2 3 1 2 3
>> |syntax error
>> |       (3 :temp)1 2 3 1 2 3
>>
>> So I read it some more and "execute statements from boxed list", hmmm.
>> Lets try that.
>>   [temp=. ;:'{. ~.'
>> +--+--+
>> |{.|~.|
>> +--+--+
>>   (3 : temp) 1 2 3 1 2 3
>> |syntax error
>> |       (3 :temp)1 2 3 1 2 3
>>
>> So I tried it this way with the data inside a variable:
>>   [data=. < every 1 2 3 1 2 3
>> +-+-+-+-+-+-+
>> |1|2|3|1|2|3|
>> +-+-+-+-+-+-+
>>      [temp=. ;:'{. ~.'
>> +--+--+
>> |{.|~.|
>> +--+--+
>>   (3 : temp) data
>> |syntax error
>> |       (3 :temp)data
>>
>> So I tried the unboxed one like so:
>>   [temp=. '{. ~.'
>> {. ~.
>>   (3 : temp) data
>> |syntax error
>> |       (3 :temp)data
>>
>> So it's not working, maybe I need to put y in like this:
>>   [temp=. '{. ~.'
>> {. ~.
>>   (3 : temp, ' y') data
>> |syntax error
>> |   (    3 :temp,' y')data
>>
>> So I thought maybe if I formatted it like this
>> (3 : '{. ~. y') data
>> So I had to wrote it this way:
>>   (3 : '''', temp, ' y''') data
>> |open quote
>> |   '
>> |   ^
>> |   (    3 :'''',temp,' y''')data
>>
>> I'm a bit stumped with your idea. Do you have an idea what I'm doing
>> wrong?
>>
>> Thanks for the suggestion though.
>>
>> r/Alex
>>
>>
>>
>>
>> -----Original Message-----
>> From: [email protected] [mailto:
>> [email protected]] On Behalf Of Björn Helgason
>> Sent: Monday, March 23, 2009 3:45 PM
>> To: Programming forum
>> Subject: Re: [Jprogramming] Executing a string command
>>
>> In the thread
>>
>> http://groups.google.com/group/J-Programming/browse_thread/thread/22d3c6d5d516491e
>>
>> "In this demo I have for the first time in an application used the
>> option of creating anonymous verbs to execute statements from a boxed
>> list.
>>
>> For some reason I have overlooked the possibilities it offers.
>>
>> C=:A (4 : V) B
>>
>> Here V is a boxed list coming from the editm field and A respectively
>> B are the left and right arguments x and y in the resulting verb.
>>
>> Similarly
>>
>> C=:(3 : V) B
>>
>> Is the monadic version of the same. "
>>
>>
>> In
>>
>> http://groups.google.com/group/J-Programming/files
>>
>> There is fall.ijs using this
>>
>> 2009/3/23 Alex Rufon <[email protected]>
>>
>> > Wow, it took some time for me to get back to this but I think I figured
>> it
>> > out.
>> >
>> > So instead of using evoke ... I used 0!:0 like so:
>> >
>> > NB. =========================================================
>> > NB.*createCMD (v) creates a temporary verb with a J sentence string
>> > NB.
>> > NB. y is: a string J sentence
>> > NB. creates a GLOBAL variable eoeCMD
>> > createCMD=: verb define
>> > temp=. 'eoeCMD=: 3 : ''', y, ' y'''
>> > 0!:0 temp
>> > )
>> >
>> >   createCMD '{. ~.'
>> >   eoeCMD ;: 'aa bb cc aa bb cc aa bb'
>> > +--+
>> > |aa|
>> > +--+
>> >
>> >   createCMD '+/'
>> >   eoeCMD i. 5 5
>> > 50 55 60 65 70
>> >
>> > I would appreciate it if somebody got a better idea. :)
>> >
>> > Thanks.
>> >
>> > r/Alex
>> >
>> >
>> > -----Original Message-----
>> > From: [email protected] [mailto:
>> > [email protected]] On Behalf Of Markus Schmidt-Gröttrup
>> > Sent: Tuesday, February 24, 2009 4:43 PM
>> > To: Programming forum
>> > Subject: Re: [Jprogramming] Executing a string command
>> >
>> > Looking to the vocabulary page of Evoke I have:
>> >
>> >   cmd =. {.
>> >   'cmd'~ (i.10)
>> > 0
>> >
>> > Regards, Markus
>> >
>> > Alex Rufon schrieb:
>> > > Hi.
>> > >
>> > > I've been tinkering with my old EDI parser and I would like to extend
>> it
>> > > with a new feature.
>> > >
>> > > NB. =========================================================
>> > > NB. AS400 File Maps
>> > > NB. Each mapping follows the following format
>> > > NB. Source*Variable*Type*Length*Decimal*Justify*Default*Remarks
>> > > NB.
>> > > NB. Valid values for each values are:
>> > > NB. Source - values corresponds to names defined in RECIEVING.IJS:
>> > > NB.   ENVELOP
>> > > NB.           PO_HEADER
>> > > NB.           PO_LINE_ITEM
>> > > NB.           DESTINATION_QUANTITY
>> > > NB.           SUB_LINE_ITEM
>> > > NB.   LOCAL - a local map specifiying non EDI retrievable values
>> > > NB. Variable - Names defined in RECIEIVING.IJS for each Source
>> > > NB. Type - Supported datatypes: CHR, NUM, DTE
>> > > NB.           note that for DATE the format will be YYYYMMDD
>> > > NB.           and for NUM there will be NO decimal/period character
>> > > NB. Length - number of characters the entry will occupy
>> > > NB. Decimal - valid only for numbers, this list the decimal positions
>> > > NB. Justify - Justification, valid values are: LJ and RJ
>> > > NB. Default - if the variable value is blank, use this value
>> > > NB. Remarks - free text, NOT USED by code
>> > > NB. Additional Operation - ADVANCED, additional operation to apply to
>> > > variable
>> > >
>> > > NB. =========================================================
>> > > NB.*PO_HEADER_MAP (n) definition for PO Header
>> > > PO_HEADER_MAP=: unbox '*' cutstring each cutopen noun define
>> > > LOCAL*SOURCE*CHR*8*0*LJ*POLO*Source Code*
>> > > ENVELOP*SENDER_QUAL*CHR*2*0*LJ**IQ*
>> > > ENVELOP*SENDER_ID*CHR*15*0*LJ**ID*
>> > > PO_HEADER*PO_NO*CHR*30*0*LJ**PO NO*
>> > > PO_HEADER*RELEASE_NO*NUM*3*0*RJ*000*PO REV*
>> > > LOCAL*EDI_REVISION*NUM*3*0*RJ*000*EDI REV*
>> > > PO_HEADER*PO_EXTRACT_DATE*DTE*8*0*LJ**PO Date*
>> > > PO_HEADER*CUST_ORDER_NO*CHR*30*0*LJ**Contract No*
>> > > LOCAL*LOT_NO*CHR*5*0*LJ**LOT No*
>> > > )
>> > >
>> > > What I want to do is add the "Additional Operation" at the end. For
>> > > example: in the entry
>> > > LOCAL*LOT_NO*CHR*5*0*LJ**LOT No*
>> > >
>> > > I want to change it to:
>> > > LOCAL*LOT_NO*CHR*5*0*LJ**LOT No*{.
>> > >
>> > > So the idea is that I would only take the first item in the data so to
>> > > simulate:
>> > >    cmd=. '{.'
>> > >    (cmd)~ i. 10
>> > > |ill-formed name
>> > > |       (cmd)~i.10
>> > >
>> > >    (".(cmd)) 1 2 3
>> > > |syntax error
>> > > |       (".(cmd))1 2 3
>> > >
>> > > What I did find out is that I can get away with it if I use the
>> > > primitives:
>> > > LOCAL*LOT_NO*CHR*5*0*LJ**LOT No*take
>> > >    cmd=. 'take'
>> > >    (cmd)~ 1 2 3
>> > > 1
>> > >
>> > > Am I missing something or I really just have to use the primitives?
>> > >
>> > > Thanks.
>> > >
>> > > r/Alex
>> > > ----------------------------------------------------------------------
>> > > For information about J forums see
>> http://www.jsoftware.com/forums.htm
>> > >
>> > >
>> > >
>> > ----------------------------------------------------------------------
>> > For information about J forums see http://www.jsoftware.com/forums.htm
>> > ----------------------------------------------------------------------
>> > For information about J forums see http://www.jsoftware.com/forums.htm
>> >
>>
>>
>>
>> --
>> Björn Helgason, Verkfræðingur
>> Fugl&Fiskur ehf,
>> Þerneyjarsundi 23, Hraunborgum
>> Po Box 127,801 Selfoss ,
>> t-póst: [email protected]
>> gsm: +3546985532
>> Landslags og skrúðgarðagerð, gröfuþjónusta
>> http://groups.google.com/group/J-Programming
>>
>>
>> Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
>>
>> góður kennari getur stigið á tær án þess að glansinn fari af skónum
>>         /|_      .-----------------------------------.
>>        ,'  .\  /  | Með léttri lund verður        |
>>    ,--'    _,'   | Dagurinn í dag                     |
>>   /       /       | Enn betri en gærdagurinn  |
>>  (   -.  |        `-----------------------------------'
>>  |     ) |         (\_ _/)
>>  (`-.  '--.)       (='.'=)   ♖♘♗♕♔♙
>>  `. )----'        (")_(") ☃☠
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>
>
>
> --
> Björn Helgason, Verkfræðingur
> Fugl&Fiskur ehf,
> Þerneyjarsundi 23, Hraunborgum
> Po Box 127,801 Selfoss ,
> t-póst: [email protected]
> gsm: +3546985532
> Landslags og skrúðgarðagerð, gröfuþjónusta
> http://groups.google.com/group/J-Programming
>
>
> Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
>
> góður kennari getur stigið á tær án þess að glansinn fari af skónum
>          /|_      .-----------------------------------.
>         ,'  .\  /  | Með léttri lund verður        |
>     ,--'    _,'   | Dagurinn í dag                     |
>    /       /       | Enn betri en gærdagurinn  |
>   (   -.  |        `-----------------------------------'
>   |     ) |         (\_ _/)
>  (`-.  '--.)       (='.'=)   ♖♘♗♕♔♙
>   `. )----'        (")_(") ☃☠
>



-- 
Björn Helgason, Verkfræðingur
Fugl&Fiskur ehf,
Þerneyjarsundi 23, Hraunborgum
Po Box 127,801 Selfoss ,
t-póst: [email protected]
gsm: +3546985532
Landslags og skrúðgarðagerð, gröfuþjónusta
http://groups.google.com/group/J-Programming


Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans

góður kennari getur stigið á tær án þess að glansinn fari af skónum
         /|_      .-----------------------------------.
        ,'  .\  /  | Með léttri lund verður        |
    ,--'    _,'   | Dagurinn í dag                     |
   /       /       | Enn betri en gærdagurinn  |
  (   -.  |        `-----------------------------------'
  |     ) |         (\_ _/)
 (`-.  '--.)       (='.'=)   ♖♘♗♕♔♙
  `. )----'        (")_(") ☃☠
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to