From bfe02651196938256c2082e892ce768dd79c0acd Mon Sep 17 00:00:00 2001 From: Massimo Melina Date: Tue, 26 May 2020 12:09:27 +0200 Subject: [PATCH] {.for line.} and {.if|var.} --- scriptLib.pas | 40 +++++++++++++++++++++++++++++++++++++++- whatsnew.txt | 4 ++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/scriptLib.pas b/scriptLib.pas index a6663ff..9c5d392 100644 --- a/scriptLib.pas +++ b/scriptLib.pas @@ -923,6 +923,37 @@ var finally free end; end; // foreach + procedure forLine(); + var + lines: TStringList; + line, code, run: string; + i: integer; + begin + code:=macroDequote(par(pars.count-1)); + with TfastStringAppend.create do + try + lines:=TStringList.create(); + lines.text:= getVar(par('var')); + for line in lines do + begin + i:=pos('=',line); + if i > 0 then + begin + setVar('line-key', Copy(line, 1, i-1)); + setVar('line-value', Copy(line, i+1, MAXINT)); + end; + setVar('line', line); + run:=code; + applyMacrosAndSymbols(run, cbMacros, cbData); + append(run); + end; + result:=reset(); + finally + Free; + lines.Free; + end; + end; //forLine + procedure for_(); var b, e, i, d: integer; @@ -2427,8 +2458,12 @@ try minOrMax(); if stringExists(name, ['if','if not']) then - if isFalse(p) xor (length(name) > 2) then result:=macroDequote(par(2)) + begin + try p:=getVar(parEx('var')); + except end; + if isTrue(p) xor (length(name) = 2) then result:=macroDequote(par(2)) else result:=macroDequote(par(1)); + end; if stringExists(name, ['=','>','>=','<','<=','<>','!=']) then trueIf(compare(name, p, par(1))); @@ -2444,6 +2479,9 @@ try if name = 'cut' then cut(); + if name ='for line' then + forLine(); + if pars.count < 3 then exit; // from here, only macros with at least 3 parameters if name ='for each' then diff --git a/whatsnew.txt b/whatsnew.txt index f9c4553..eb98c8e 100644 --- a/whatsnew.txt +++ b/whatsnew.txt @@ -12,12 +12,16 @@ propaganda Mobile-friendly template Unicode support Encrypted login, and logout + IPv6 /propaganda + new default template + new login system, session based, with logout ++ IPv6 support + {.set item|name.} + {.get item|icon.} + {.set cfg.} ++ {.for line.} ++ {.if|var} + cache for jquery and template sections + new template commands: base64, base64decode, md5, sha1 + *.diff.tpl in exe's folder