Date Variables: How to escape the "." (DOT not supported?)

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Filehero
Posts: 2731
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Date Variables: How to escape the "." (DOT not supported?)

Post by Filehero »

Hi,

I want to output a simple formatted date, however the "." seemingly isn't supported (line #2).

Code: Select all

  $date_ok = <date dd-mm-yyyy>;
  $date_broken = <date dd.mm.yyyy>;  // ???????? or is it a Bug?
  $date_stillbroken = eval(<date dd.mm.yyyy>); 
  $DOT = ".";
  $date_fun = <date dd$DOTmm$DOTyyyy>; // funny
  
  msg($date_ok<br>$date_broken<br>$date_stillbroken<br>$date_fun);
Do I need to escape it somehow, or is it rather a bug?


/e: replaced datem by the correct date

Cheers,
Filehero

admin
Site Admin
Posts: 66351
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Date Variables: How to escape the "." (DOT not supported

Post by admin »

You have to quote it, else the "." are processed as concatenators.

Code: Select all

echo "<date dd.mm.yyyy>";

Filehero
Posts: 2731
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: Date Variables: How to escape the "." (DOT not supported

Post by Filehero »

Moin,
admin wrote:You have to quote it, else the "." are processed as concatenators.
thanks. The outer quotes I hadn't tried - only all sorts of quoting/masking including the dots inside, arghh.

Maybe you can just add this tip to manual.

/e: fixed typo

Cheers,
Filehero
Last edited by Filehero on 21 Jul 2014 15:36, edited 1 time in total.

admin
Site Admin
Posts: 66351
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Date Variables: How to escape the "." (DOT not supported

Post by admin »

Well, you should quote all literal strings. Unquoted strings are only tolerated but not recommended.

Filehero
Posts: 2731
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: Date Variables: How to escape the "." (DOT not supported

Post by Filehero »

admin wrote:Well, you should quote all literal strings.
I do, but for whatever reason I thought I haven't to do that for XY's built-in variables.


cheers,
Filehero

admin
Site Admin
Posts: 66351
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Date Variables: How to escape the "." (DOT not supported

Post by admin »

Well, I make the same mistake once in a while. That's because it mostly works, but it does not work when there are dots in it.

Filehero
Posts: 2731
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: Date Variables: How to escape the "." (DOT not supported

Post by Filehero »

admin wrote:Well, I make the same mistake once in a while. That's because it mostly works, but it does not work when there are dots in it.
Good to know it's a boss-error. :lol:

Maybe adding a little hint to the quote section my reduce the number even more, such as Note, this rule also applies when using all kind of XY-provided variables (<linked to variables section>), e.g. msg("<date dd.mm.yyyy>") or echo("%personal%").


Cheers,
Filehero

PeterH
Posts: 2827
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Date Variables: How to escape the "." (DOT not supported

Post by PeterH »

I don't think this is consistent :veryconfused:

For me these are (XY-)variables - and it would be strange if they must be quoted.

But OK: assume they are not variables - and write them with single quotes :shock:

Sorry: it don't feels right this way 8)

admin
Site Admin
Posts: 66351
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Date Variables: How to escape the "." (DOT not supported

Post by admin »

PeterH wrote:For me these are (XY-)variables - and it would be strange if they must be quoted.
Agreed, next version will improve it.

PeterH
Posts: 2827
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Date Variables: How to escape the "." (DOT not supported

Post by PeterH »

admin wrote:
PeterH wrote:For me these are (XY-)variables - and it would be strange if they must be quoted.
Agreed, next version will improve it.
If I understand it correct <...> variables are now handled same as $... variables. I think just logical.

This should also be documented: they can be used unquoted and in double quotes.

Post Reply