rejetto forum

Macro issues

0 Members and 1 Guest are viewing this topic.

Offline MegaGamerGuy

  • Occasional poster
  • *
    • Posts: 20
    • View Profile
the exec macro is executed regardless of the if macro's return value. Basically I check to see if a file exists, if not run command to create it. well, weather or not the file exists the command runs. But, if i put "NaN" without quotes where the exec statement would go...NaN will show up in the html source when there is no file, but not when there is a file.

Thanks, and long time no see guys!


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
the instructions "covered" by an IF must be {:quoted:}

{.if| condition | {: then :} .}

i know it's strange. It's a strange and stupid language.
Sorry for the late reply.


Offline MegaGamerGuy

  • Occasional poster
  • *
    • Posts: 20
    • View Profile
This is what I have

{.set|ItemPath|{.vfs to disk|%item-url%.}.}
{.set|ItemMD5|{.md5 file|{.call|ItemPath.}.}.}
{.set|ItemIconUrl|/Data/Media/Graphics/Icons/Cache/%item-name%.{.call|ItemMD5.}.png.}
{.set|ItemIconPath|Data\Media\Graphics\Icons\Cache\%item-name%.{.call|ItemMD5.}.png.}
{.if not|{.and|{.exists|^ItemIconPath.}|{.is file|^ItemIconPath.}.}|{.exec|Data\Path2Png.exe|{.Call|ItemPath.} Data\Media\Graphics\Icons\Cache\%item-name%.{.call|ItemMD5.}.png 32.}.}


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
{.if not|{.and|{.exists|{.^ItemIconPath.}.}|{.is file|{
.^ItemIconPath.}.}.}
          |{:
              {.exec|Data\Path2Png.exe
                       |{.Call|ItemPath.} Data\Media\Graphics\Icons\Cache\%item-name%.{.call|ItemMD5.}.png 32.}
           :}
.}
« Last Edit: September 20, 2014, 01:05:36 PM by Mars »


Offline MegaGamerGuy

  • Occasional poster
  • *
    • Posts: 20
    • View Profile
still executing regardless of the existence of png file in  /Data/Media/Graphics/Icons/Cache


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
that's because there is an error in your script.
i will describe in details the problem, for those who like to learn from it.
Preamble: this programming language sucks.
Commands {.is file.} and {.exists.} work directly with the name of the file, not with variables
(few commands are able to work directly with variables, you know them because often they have a parameter called "var").
Since you have the name inside variable ItemIconPath, you have to use a specific command to access its value first.
The command is {.call|ItemIconPath.} or its shortcut {.^ItemIconPath.}
So, here we get to your problem: you put braces {} for the command "exists" but not for the command ^
You wrote {.exists|^ItemIconPath.}
but it is {.exists|{.^ItemIconPath.}.}

the same for is-file