Re: Local Versus Global Command Options

Liste des GroupesRevenir à co vms 
Sujet : Re: Local Versus Global Command Options
De : arne (at) *nospam* vajhoej.dk (Arne Vajhøj)
Groupes : comp.os.vms
Date : 15. Feb 2025, 02:02:20
Autres entêtes
Organisation : SunSITE.dk - Supporting Open source
Message-ID : <67afe79c$0$719$14726298@news.sunsite.dk>
References : 1 2 3 4 5
User-Agent : Mozilla Thunderbird
On 2/14/2025 6:49 PM, Arne Vajhøj wrote:
On 2/14/2025 2:02 PM, Simon Clubley wrote:
                                                             It also
doesn't help you with the main problem I mentioned, which is parsing
and validating the filter syntax.
 
How would you turn the list of filters, each with their own syntax, into
something that can be validated by DCL ? As a reminder, it is critical
that the filters are available to the program in the order they were
specified on the command line.
 I think that can be define in CLD.
 $ type fun4.cld
define verb fun4
     image "sys$disk:[]fun4"
     parameter p1, value(type=$file, list, required)
qualifier filter, value(type=filter_type, list, required), placement=local
define type filter_type
     keyword filtera, value(type=filtera_type, list, required)
     keyword filterb, value(type=filterb_type, list, required)
define type filtera_type
     keyword a1, value(type=$number, required)
     keyword a2, value(type=$number, required)
     keyword x, value(type=$number, required)
define type filterb_type
     keyword b1, value(type=$number, required)
     keyword b2, value(type=$number, required)
     keyword x, value(type=$number, required)
$ type fun4.pas
[inherit('sys$library:pascal$cli_routines')]
program fun4(input,output);
 type
    pstr = varying [255] of char;
    filter_type = (filtera, filterb);
 var
    filter_list : array [1..100] of filter_type;
    fnm, filter, a1, a2, b1, b2, x : pstr;
    nfilters, i : integer;
 begin
    while odd(cli$get_value('P1', fnm.body, fnm.length)) do begin
       write(fnm);
       nfilters := 0;
       while odd(cli$get_value('FILTER', filter.body, filter.length)) do begin
          nfilters := nfilters + 1;
          if index(filter, 'FILTERA') = 1 then
             filter_list[nfilters] := filtera
          else if index(filter, 'FILTERB') = 1 then
             filter_list[nfilters] := filterb
          else
             halt;
       end;
       for i := 1 to nfilters do begin
          write(' ', filter_list[i]);
          case filter_list[i] of
             filtera:
                begin
                   write(' filtera');
                   cli$get_value('FILTERA.A1', a1.body, a1.length);
                   write(' a1=', a1);
                   cli$get_value('FILTERA.A2', a2.body, a2.length);
                   write(' a2=', a2);
                   cli$get_value('FILTERA.X', x.body, x.length);
                   write(' x=', x);
                end;
             filterb:
                begin
                   write(' filterb');
                   cli$get_value('FILTERB.B1', b1.body, b1.length);
                   write(' b1=', b1);
                   cli$get_value('FILTERB.B2', b2.body, b2.length);
                   write(' b2=', b2);
                   cli$get_value('FILTERB.X', x.body, x.length);
                   write(' x=', x);
                end;
          end;
       end;
       writeln;
    end;
end.
$ pas fun4
$ lin fun4
$ set comm fun4
$ fun4 f1.dat/ filter=(filtera=(a1:12,a2:34,x:1234),filterb=(b1:56,b2:78,x:5678)),-
 f2.dat/filter=(filterb=(b2:87,b1:65,x:8765),filtera=(a2:43,a1:21,x:4321))
f1.dat  FILTERA filtera a1=12 a2=34 x=1234  FILTERB filterb b1=56 b2=78 x=5678
f2.dat  FILTERB filterb b1=65 b2=87 x=8765  FILTERA filtera a1=21 a2=43 x=4321
But I like this version better:
$ type fun5.cld
define verb fun5
     image "sys$disk:[]fun5"
     parameter p1, value(type=$file, list, required)
qualifier filter, value(type=$quoted_string, list, required), placement=local
$ type fun5sup.cld
module fun5sup
define verb fa
     qualifier a1, value(type=$number, required)
     qualifier a2, value(type=$number, required)
     qualifier x, value(type=$number, required)
define verb fb
     qualifier b1, value(type=$number, required)
     qualifier b2, value(type=$number, required)
     qualifier x, value(type=$number, required)
$ type fun5.pas
[inherit('sys$library:pascal$cli_routines')]
program fun5(input,output);
type
    pstr = varying [255] of char;
    finfo = record
               fnm : pstr;
               nfilter : integer;
               filter_list : array [1..100] of pstr;
            end;
var
    fun5sup : [external] integer;
var
    finfo_list : array [1..100] of finfo;
    fnm, filter, a1, a2, b1, b2, x : pstr;
    n, i, j : integer;
begin
    n := 0;
    while odd(cli$get_value('P1', fnm.body, fnm.length)) do begin
       n := n + 1;
       finfo_list[n].fnm := fnm;
       finfo_list[n].nfilter := 0;
       while odd(cli$get_value('FILTER', filter.body, filter.length)) do begin
          finfo_list[n].nfilter := finfo_list[n].nfilter + 1;
          finfo_list[n].filter_list[finfo_list[n].nfilter] := substr(filter, 2, length(filter) - 2);
       end;
    end;
    for i := 1 to n do begin
       write(finfo_list[i].fnm);
       for j := 1 to finfo_list[i].nfilter do begin
          cli$dcl_parse(finfo_list[i].filter_list[j], fun5sup);
          if index(finfo_list[i].filter_list[j], 'fa') = 1 then begin
             write(' fa');
             cli$get_value('A1', a1.body, a1.length);
             write(' a1=', a1);
             cli$get_value('A2', a2.body, a2.length);
             write(' a2=', a2);
             cli$get_value('X', x.body, x.length);
             write(' x=', x);
          end else if index(finfo_list[i].filter_list[j], 'fb') = 1 then begin
             write(' fb');
             cli$get_value('B1', b1.body, b1.length);
             write(' b1=', b1);
             cli$get_value('B2', b2.body, b2.length);
             write(' b2=', b2);
             cli$get_value('X', x.body, x.length);
             write(' x=', x);
          end else begin
             halt;
          end;
       end;
       writeln;
    end;
end.
$ set comm/obj fun5sup
$ pas fun5
$ lin fun5 + fun5sup
$ set comm fun5
$ fun5 f1.dat/filter=("fa /a1=12 /a2:34 /x=1234","fb /b1=56 /b2=78 /x=5678"),-
        f2.dat/filter=("fb /b2=87 /b1:65 /x:8765","fa /a2=43 /a1=21 /x=4321")
f1.dat fa a1=12 a2=34 x=1234 fb b1=56 b2=78 x=5678
f2.dat fb b1=65 b2=87 x=8765 fa a1=21 a2=43 x=4321
Arne

Date Sujet#  Auteur
13 Feb 25 * Local Versus Global Command Options53Lawrence D'Oliveiro
14 Feb 25 +* Re: Local Versus Global Command Options2Arne Vajhøj
14 Feb 25 i`- Re: Local Versus Global Command Options1Arne Vajhøj
14 Feb 25 +* Re: Local Versus Global Command Options49Simon Clubley
14 Feb 25 i+* Re: Local Versus Global Command Options44Arne Vajhøj
14 Feb 25 ii`* Re: Local Versus Global Command Options43Simon Clubley
15 Feb 25 ii `* Re: Local Versus Global Command Options42Arne Vajhøj
15 Feb 25 ii  `* Re: Local Versus Global Command Options41Arne Vajhøj
15 Feb 25 ii   +* Re: Local Versus Global Command Options2Arne Vajhøj
18 Feb 25 ii   i`- Re: Local Versus Global Command Options1Arne Vajhøj
15 Feb 25 ii   `* Re: Local Versus Global Command Options38Lawrence D'Oliveiro
16 Feb 25 ii    +- Re: Local Versus Global Command Options1Arne Vajhøj
16 Feb 25 ii    `* Re: Local Versus Global Command Options36Mark Berryman
17 Feb 25 ii     `* Re: Local Versus Global Command Options35Lawrence D'Oliveiro
17 Feb 25 ii      `* Re: Local Versus Global Command Options34Mark Berryman
17 Feb 25 ii       +* Re: Local Versus Global Command Options2bill
17 Feb 25 ii       i`- Re: Local Versus Global Command Options1Robert A. Brooks
17 Feb 25 ii       `* Re: Local Versus Global Command Options31Lawrence D'Oliveiro
18 Feb 25 ii        +* Re: Local Versus Global Command Options4jayjwa
18 Feb 25 ii        i+- Re: Local Versus Global Command Options1Arne Vajhøj
18 Feb 25 ii        i+- Re: Local Versus Global Command Options1Lawrence D'Oliveiro
18 Feb 25 ii        i`- Re: Local Versus Global Command Options1Lawrence D'Oliveiro
18 Feb 25 ii        +* Re: Local Versus Global Command Options2Arne Vajhøj
18 Feb 25 ii        i`- Re: Local Versus Global Command Options1Lawrence D'Oliveiro
18 Feb 25 ii        `* Re: Local Versus Global Command Options24Mark Berryman
19 Feb 25 ii         `* Re: Local Versus Global Command Options23Lawrence D'Oliveiro
19 Feb 25 ii          `* Re: Local Versus Global Command Options22Arne Vajhøj
19 Feb 25 ii           +* Re: Local Versus Global Command Options20Dan Cross
19 Feb 25 ii           i`* Re: Local Versus Global Command Options19Robert A. Brooks
19 Feb 25 ii           i `* Re: Local Versus Global Command Options18Arne Vajhøj
19 Feb 25 ii           i  +* Re: Local Versus Global Command Options16Dan Cross
21 Feb 25 ii           i  i`* Re: Local Versus Global Command Options15Stephen Hoffman
21 Feb 25 ii           i  i `* Re: Local Versus Global Command Options14Lawrence D'Oliveiro
22 Feb 25 ii           i  i  +* Re: Local Versus Global Command Options10Arne Vajhøj
22 Feb 25 ii           i  i  i`* Re: Local Versus Global Command Options9Lawrence D'Oliveiro
22 Feb 25 ii           i  i  i `* Re: Local Versus Global Command Options8Arne Vajhøj
22 Feb 25 ii           i  i  i  +* Re: Local Versus Global Command Options6Dave Froble
22 Feb 25 ii           i  i  i  i`* Re: Local Versus Global Command Options5Arne Vajhøj
22 Feb 25 ii           i  i  i  i `* Re: Local Versus Global Command Options4Arne Vajhøj
22 Feb 25 ii           i  i  i  i  +* Re: Local Versus Global Command Options2Dave Froble
22 Feb 25 ii           i  i  i  i  i`- Re: Local Versus Global Command Options1Arne Vajhøj
22 Feb 25 ii           i  i  i  i  `- Re: Local Versus Global Command Options1Lawrence D'Oliveiro
22 Feb 25 ii           i  i  i  `- Re: Local Versus Global Command Options1Lawrence D'Oliveiro
22 Feb 25 ii           i  i  `* Re: Local Versus Global Command Options3Dave Froble
22 Feb 25 ii           i  i   `* Re: Local Versus Global Command Options2Dan Cross
22 Feb 25 ii           i  i    `- Re: Local Versus Global Command Options1Chris Townley
20 Feb 25 ii           i  `- Re: Local Versus Global Command Options1Lawrence D'Oliveiro
20 Feb 25 ii           `- Re: Local Versus Global Command Options1Lawrence D'Oliveiro
22 Feb 25 i`* Re: Local Versus Global Command Options4Brian Schenkenberger
22 Feb 25 i +* Re: Local Versus Global Command Options2Lawrence D'Oliveiro
22 Feb 25 i i`- Re: Local Versus Global Command Options1Dave Froble
24 Feb 25 i `- Re: Local Versus Global Command Options1Simon Clubley
5 Mar 25 `- Re: Local Versus Global Command Options1Lawrence D'Oliveiro

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal