Skip to content

Commit

Permalink
Catch-action
Browse files Browse the repository at this point in the history
  • Loading branch information
tvannini committed Oct 22, 2023
1 parent 026970b commit cb69b67
Show file tree
Hide file tree
Showing 9 changed files with 523 additions and 370 deletions.
21 changes: 14 additions & 7 deletions checkprg.pas
Expand Up @@ -1498,19 +1498,26 @@ procedure Tf_checkprg.check_azioniExecute(Sender: TObject);
t_azioni.First;
while not t_azioni.EOF do
begin

nome_azione := t_azioniazione.Value;

// parte con le operazioni
// ________________________________________ Check catch-action, if any ___
if (t_azionicatch_action.Value <> '') and
errazione(t_azionicatch_action.Value, false) then
begin
Memo2.Lines.Append('Action: ' + nome_azione + '. Action "' +
t_azionicatch_action.Value +
'" requested as catch-action not found');
end;
// ________________________________________________ Loop on operations ___
t_operazioni.First;
while not t_operazioni.EOF do
begin

// se c'è una condizione di esecuzione deve esistere per tutte le operazioni
// ____________________________ Check execution condition expression ___
if errexp(t_operazioniexp2.AsString) then
begin
Memo2.Lines.Append('Action: ' + nome_azione + ' Line: ' + t_operazioniid.AsString +
'. Expression "'+ t_operazioniexp2.AsString +'" not found')
Memo2.Lines.Append('Action: ' + nome_azione +
' Line: ' + t_operazioniid.AsString +
'. Expression "' + t_operazioniexp2.AsString +
'" not found');
end;

// _________________________ operatore RECORDSET (Controllo la view) ___
Expand Down
9 changes: 6 additions & 3 deletions dm.dfm
Expand Up @@ -2183,7 +2183,7 @@ object dm_form: Tdm_form
item
Name = 'fine'
DataType = ftString
Size = 20
Size = 50
end
item
Name = 'exp_fine'
Expand Down Expand Up @@ -2226,8 +2226,10 @@ object dm_form: Tdm_form
OnSetText = t_azioniazioneSetText
Size = 40
end
object t_azionifine: TStringField
object t_azionicatch_action: TStringField
DisplayLabel = 'catch_action'
FieldName = 'fine'
Size = 50
end
object t_azioniexp_fine: TIntegerField
FieldName = 'exp_fine'
Expand Down Expand Up @@ -3723,7 +3725,8 @@ object dm_form: Tdm_form
DataSet = tab_ope
Left = 872
Top = 448
end object tab_tipi_file: TClientDataSet
end
object tab_tipi_file: TClientDataSet
Aggregates = <>
Params = <>
Left = 952
Expand Down
2 changes: 1 addition & 1 deletion dm.pas
Expand Up @@ -145,7 +145,7 @@ Tdm_form = class(TDataModule)
t_operazionio2ref: TStringField;
t_azioniexp_fine: TIntegerField;
t_azionichunk_size: TIntegerField;
t_azionifine: TStringField;
t_azionicatch_action: TStringField;
t_programmiref: TStringField;
t_controlliformscelte_possibili: TStringField;
t_controlliformvocecss: TStringField;
Expand Down
44 changes: 32 additions & 12 deletions export.pas
Expand Up @@ -152,7 +152,15 @@ procedure Tf_export.prg_exportExecute(Sender: TObject; newnomeprg: string);
repeat
if t_azioniazione.Value <> '' then
begin
Memo2.Add('o2def::act("' + t_azioniazione.Value + '");');
if t_azionicatch_action.Value <> '' then
begin
Memo2.Add('o2def::act("' + t_azioniazione.Value + '", "' +
t_azionicatch_action.Value + '");');
end
else
begin
Memo2.Add('o2def::act("' + t_azioniazione.Value + '");');
end;
end;
t_azioni.Next
until (t_azioni.EOF); // ___________________________ End loop on actions ___
Expand Down Expand Up @@ -1959,32 +1967,36 @@ procedure Tf_export.prg_exportExecute(Sender: TObject; newnomeprg: string);
until t_form.EOF;


// AZIONI
// ___________________________________________________________ ACTIONS ___
t_azioni.First;
repeat
if t_azioniazione.Value <> '' then
begin
Memo3.Add('');


buffer := 'function ' + nomeprg + '§§' + t_azioniazione.Value + '_act(&$o2exe) {';
buffer := 'function ' + nomeprg + '§§' +
t_azioniazione.Value + '_act(&$o2exe) {';
Memo3.Add(buffer);
// ________________________________________ If catch-action is set ___
if t_azionicatch_action.Value <> '' then
begin
buffer := chr(9) + 'try {';
Memo3.Add(buffer);
end;
buffer := '';

//ISTRUZIONI DELL'AZIONE
// __________________________________________________ ACtion steps ___
t_operazioni.First;
repeat

if (t_operazioniexp2.Value = 0) then
begin
condizione := 'True'
end
else begin
condizione := '(' + nomeprg + '_exp_' + t_operazioniexp2.AsString + '() || $o2exe->e())'
condizione := '(' + nomeprg + '_exp_' +
t_operazioniexp2.AsString + '() || $o2exe->e())'
end;
inizioact := chr(9) + '$o2exe->s(' + t_operazioniid.AsString + ') && ' +
condizione + ' && ';
//if t_operazionioperazione.Value='Go to program' then fineact:='&& $o2exe->t();' else fineact:='&& $o2exe->e();';
inizioact := chr(9) + '$o2exe->s(' + t_operazioniid.AsString +
') && ' + condizione + ' && ';
fineact := '&& $o2exe->e();';

if t_operazionioperazione.Value = 'Block' then
Expand Down Expand Up @@ -2476,7 +2488,15 @@ procedure Tf_export.prg_exportExecute(Sender: TObject; newnomeprg: string);

t_operazioni.Next;
until t_operazioni.EOF;

// ________________________________________ If catch-action is set ___
if t_azionicatch_action.Value <> '' then
begin
Memo3.Add(chr(9) + '}');
Memo3.Add(chr(9) + 'catch (Throwable $error) {');
Memo3.Add(chr(9) + chr(9) + 'o2act::catch($error, $o2exe);');
Memo3.Add(chr(9) + chr(9) + '}');
end;
// _____________________________________________ End action script ___
buffer := chr(9) + '} //|o2_fine_act|';
Memo3.Add(buffer);
end;
Expand Down
62 changes: 8 additions & 54 deletions import.pas
Expand Up @@ -59,7 +59,6 @@ Tf_import = class(TForm)
public
build_1_file: integer;
build_file: string;
crossref_oggetto, crossref_ricerca, crossref_ricerca_parent : string;
function decodifica_css(stringa: string): string;
function decodifica_exp(stringa, nomeprogramma: string): string;
function form_val_prop(proprieta, nomeform, selezione3: string;
Expand All @@ -77,7 +76,7 @@ Tf_import = class(TForm)

implementation

uses dm, work, start, conversioni, crossref, sceltacampiprg, export;
uses dm, work, start, conversioni, sceltacampiprg, export;

{$R *.dfm}

Expand Down Expand Up @@ -354,24 +353,24 @@ procedure Tf_import.prg_importExecute(Sender: TObject; nomeprogramma: string);
programma.SelLength := r.MatchLen[0];
selezione := programma.SelText;
r2.Expression := '\(.*\)';

if r2.exec(selezione) then
begin
selezione2 := copy(r2.match[0], 2, r2.MatchLen[0] - 2);
// _____________________________________________________ Action name ___
par1 := extractword(1, selezione2, [',']);
par1 := copy(par1, 2, length(trim(par1)) - 2);
par1 := copy(trim(par1), 2, length(trim(par1)) - 2);
// ____________________________________________________ Catch-action ___
par2 := extractword(2, selezione2, [',']);
par2 := copy(trim(par2), 2, length(trim(par2)) - 2);
with dm_form do
begin
t_azioni.Insert;
t_azioniprg.Value := nomeprg;
t_azioniazione.Value := par1;
t_azioniprg.Value := nomeprg;
t_azioniazione.Value := par1;
t_azionicatch_action.Value := par2;
t_azioni.Post;
end;
end;



until not r.ExecNext
end;

Expand Down Expand Up @@ -1200,11 +1199,6 @@ procedure Tf_import.prg_importExecute(Sender: TObject; nomeprogramma: string);
dm_form.t_reportfield.InsertRecord(
[nomeprg, t_reportalias.Value, num1, chr(127) + par1 + chr(129) + par2, par3, par4]);


if (crossref_oggetto = 'Application variable') and (crossref_ricerca = par2) and (par1 = '_o2SESSION') then
f_crossref.Memo1.Lines.Append('Program: [' + nomeprg + ']' +chr(9)+ 'Protocol: [' + t_reportalias.Value + ']'
+chr(9) + 'Line: [' + inttostr(num1) +']');

end;

until not r.ExecNext
Expand Down Expand Up @@ -1549,12 +1543,6 @@ procedure Tf_import.prg_importExecute(Sender: TObject; nomeprogramma: string);
par8 := trim(extractword(5, selezione2, [',']));
par8 := copy(par8, 2, length(trim(par8)) - 2);

if (crossref_oggetto = 'Application variable') and (crossref_ricerca = par8) and (par2 ='_o2SESSION')
then
f_crossref.Memo1.Lines.Append('Program: [' + nomeprg + ']' + chr(9) +
'Form: [' + t_formnomeform.Value + ']' + chr(9) +
'Control: [' + nomecontrollo + ']');

//riferimento(task+campo)
if (par2 <> '') then
begin
Expand Down Expand Up @@ -2170,11 +2158,6 @@ procedure Tf_import.prg_importExecute(Sender: TObject; nomeprogramma: string);
par8 := extractword(2, selezione3, [',']);
par8 := copy(trim(par8), 2, length(trim(par8)) - 2);

if (crossref_oggetto = 'Application variable') and (crossref_ricerca = par8) and (par3 = CHR(127) + '_o2SESSION') then
f_crossref.Memo1.Lines.Append('Program: [' + nomeprg + ']' +chr(9)+ 'Action: [' + t_azioniazione.Value + ']'
+chr(9) + 'Line: [' + par1 +']');


par3 := trim(par3) + chr(129) + par8;
//valore exp1
par6 := trim(extractword(3, selezione3, [',']));
Expand All @@ -2194,10 +2177,6 @@ procedure Tf_import.prg_importExecute(Sender: TObject; nomeprogramma: string);
par8 := extractword(2, selezione3, [',']);
par8 := copy(trim(par8), 2, length(trim(par8)) - 2);

if (crossref_oggetto = 'Application variable') and (crossref_ricerca = par8) and (par3 = CHR(127) + '_o2SESSION') then
f_crossref.Memo1.Lines.Append('Program: [' + nomeprg + ']' +chr(9)+ 'Action: [' + t_azioniazione.Value + ']'
+chr(9) + 'Line: [' + par1 +']');

par3 := trim(par3) + chr(129) + par8;
//valore exp1
par6 := trim(extractword(3, selezione3, [',']));
Expand Down Expand Up @@ -2324,11 +2303,6 @@ procedure Tf_import.prg_importExecute(Sender: TObject; nomeprogramma: string);
end;
if pos('§§', par8) > 0 then
begin

if (crossref_oggetto = 'Application variable') and (crossref_ricerca = extractword(2, par8, ['§'])) and (Pos('_o2SESSION', par8) > 0) then
f_crossref.Memo1.Lines.Append('Program: [' + nomeprg + ']' +chr(9)+ 'Action: [' + t_azioniazione.Value + ']'
+chr(9) + 'Line: [' + par1 +']');

par8 := chr(127) + Stringreplace(par8, '§§', chr(129), [rfReplaceAll])
end;

Expand Down Expand Up @@ -2387,9 +2361,6 @@ procedure Tf_import.prg_importExecute(Sender: TObject; nomeprogramma: string);
par8 := copy(trim(par8), 2, length(trim(par8)) - 2);
if pos('§§', par8) > 0 then
begin
if (crossref_oggetto = 'Application variable') and (crossref_ricerca = extractword(2, par8, ['§'])) and (Pos('_o2SESSION', par8) > 0) then
f_crossref.Memo1.Lines.Append('Program: [' + nomeprg + ']' +chr(9)+ 'Action: [' + t_azioniazione.Value + ']'
+chr(9) + 'Line: [' + par1 +']');
par8 := chr(127) + Stringreplace(par8, '§§', chr(129), [rfReplaceAll])
end;
end
Expand Down Expand Up @@ -2712,21 +2683,6 @@ procedure Tf_import.prg_importExecute(Sender: TObject; nomeprogramma: string);
t_espressioni.InsertRecord([nomeprg, i, par2, par1]);
end;

if crossref_ricerca <> '' then
begin
// mette script e return in un' unica stringa
par2 := trim(par2) + trim(par1);
if (crossref_oggetto = 'Application variable') then par13:= '_o2SESSION';


r3.Expression:='o2(val|pre|zero)\((\x27|\")('+ par13 +')(\x27|\")\s*,\s*(\x27|\")('+ crossref_ricerca +')(\x27|\")';

if r3.Exec(par2) then
f_crossref.Memo1.Lines.Append('Program: [' + nomeprg + ']' +chr(9)+ 'Expression: [' + inttostr(i) + ']');

// end;

end;
end;
until not r.ExecNext
end;
Expand All @@ -2753,8 +2709,6 @@ procedure Tf_import.prg_importExecute(Sender: TObject; nomeprogramma: string);

// se non esistono i files cds li crea
if dircds = '' then f_export.prgsavcdsExecute(self, nomeprg);
crossref_oggetto:='';
crossref_ricerca:='';
dm_form.in_importazione:=false;
f_work.abilitaprgtab.Execute;
end; // fine import prg
Expand Down
Binary file added interface_imgs/action2.bmp
Binary file not shown.
Binary file added interface_imgs/png/prgbar/act2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cb69b67

Please sign in to comment.