Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
if text contains...
#1
how to program that...

if text contains a date, like 22.08.2011 22:32, --> do end macro

that could only be sth. like: "if text contains "2011" --> end macro"

or if text begins with numbers, --> end macro.

and another question:
if text contains "today" then replace that with the current date e.g. 26.08.2011
and if text contains "yesterday", then replace that with the current date minus one day

I want to do that so, that some list of entries will be changed either if the entry do not contain any date, the date will be get from some place and added, -- so long the macro runs well --
or if some date has been added before, the macro stops,
or if the text, from where the date schould be readed contains "yesterday" or "today" then a current date or current date minus one day is replaced.

firstly I look for s.th to end the macro. Smile

is it anyhow possible, to get yesterdays date?
(easy in one month, but what, if the date of yesterday the 1.3.2011 must be a 28.2.2011?
- is such thing possible at all?) :roll:
#2
Macro Macro1526
Code:
Copy      Help
out
str s

s="55 aaaa 22.08.2011 22:32 bbbbbbbb"

if(findrx(s "\d\d\.\d\d\.\d\d\d\d \d\d:\d\d" 0 2)>=0) out "s contains a date like 22.08.2011 22:32"

if(findrx(s "\d\d\d\d" 0 2)>=0) out "s contains a 4-digit number"

if(findrx(s "^\d")>=0) out "s begins with a digit"

;-----------

s="aaaa today bbbbbbbbb yesterday cccccc"

DateTime today yesterday
today.FromComputerTime
yesterday=today; yesterday.AddParts(-1)
s.findreplace("today" today.ToStr(1) 1|2)
s.findreplace("yesterday" yesterday.ToStr(1) 1|2)
out s


Forum Jump:


Users browsing this thread: 1 Guest(s)