Loading ...
Sorry, an error occurred while loading the content.
 

Re: [cw] Sunday at Riely

Expand Messages
  • xyzzy
    I m trying to write a filter for HTML (for GURPS 3) that s a little more decorated than the default. I tried to put a macro expansion inside a macro expansion,
    Message 1 of 5 , Sep 1, 2010
      I'm trying to write a filter for HTML (for GURPS 3) that's a little more decorated than the default. I tried to put a macro expansion inside a macro expansion, like this:

      $$namevaluerow(Dodge:,$$showDodge(),name,value)

      It seems not to work. In particular, it makes Metacreator 4.1.1 crash, I'm guessing from some kind of overrun, since the crash takes several seconds.

      Here are the macro definitions:

      $$macro namevaluerow(name,value,nameClass,valueClass,test)
      {{
      $$ifdef(test)
      @assign _check = $(test)
      $$else
      @assign _check = 1
      $$endif
      @if _check
      <tr>
      <td$$ifdef(nameClass) class="$(nameClass)"$$endif>$(name)</td>
      <td$$ifdef(valueClass) class="$(valueClass)"$$endif>$(value)</td>
      </tr>
      @endif
      }}

      and

      $$macro showDodge(j){{%u_dodge%?u_dodge!=dodge?/%dodge%??}}

      Reference Manual p.232  (bottom) says macros may be nested to a depth of 10, so I'm assuming this works and I have made some sort of syntax error, but I can't figure out what it might be.

      By the way, this

      $$namevaluerow(Dodge:,%u_dodge%?u_dodge!=dodge?/%dodge%??,name,value)

      produces the expected behavior. The only difference is that I manually replaced $$showDodge() with its expansion.

      Anyone care to help?

      Thanks.
    • Support
      Actually, you can t pass macro calls to macros. The nesting referred to is macros calling other macros, to prevent infinite recursion of this sort:: $$macro
      Message 2 of 5 , Sep 1, 2010
        Actually, you can't pass macro calls to macros.

        The nesting referred to is macros calling other macros, to prevent infinite recursion of this sort::

        $$macro x()
        {{
            $$y()
        }}

        $$macro y()
        {{
            $$z()
        }}

        $$macro z()
        {{
            $$x()
        }}

        You might look into using @sub definitions for your filter rather than macros.

        On 9/1/2010 1:33 PM, xyzzy wrote:
        I'm trying to write a filter for HTML (for GURPS 3) that's a little more decorated than the default. I tried to put a macro expansion inside a macro expansion, like this:

        $$namevaluerow(Dodge:,$$showDodge(),name,value)

        It seems not to work. In particular, it makes Metacreator 4.1.1 crash, I'm guessing from some kind of overrun, since the crash takes several seconds.

        Here are the macro definitions:

        $$macro namevaluerow(name,value,nameClass,valueClass,test)
        {{
        $$ifdef(test)
        @assign _check = $(test)
        $$else
        @assign _check = 1
        $$endif
        @if _check
        <tr>
        <td$$ifdef(nameClass) class="$(nameClass)"$$endif>$(name)</td>
        <td$$ifdef(valueClass) class="$(valueClass)"$$endif>$(value)</td>
        </tr>
        @endif
        }}

        and

        $$macro showDodge(j){{%u_dodge%?u_dodge!=dodge?/%dodge%??}}

        Reference Manual p.232  (bottom) says macros may be nested to a depth of 10, so I'm assuming this works and I have made some sort of syntax error, but I can't figure out what it might be.

        By the way, this

        $$namevaluerow(Dodge:,%u_dodge%?u_dodge!=dodge?/%dodge%??,name,value)

        produces the expected behavior. The only difference is that I manually replaced $$showDodge() with its expansion.

      • xyzzy
        Thanks for clearing the macro issue up. Can one omit arguments to filter subroutines defined by @sub, i.e. will the following work? @sub text(x,y) ... @endsub
        Message 3 of 5 , Sep 2, 2010
          Thanks for clearing the macro issue up.

          Can one omit arguments to filter subroutines defined by @sub, i.e. will the following work?

          @sub text(x,y)
          ...
          @endsub

          ...

          @text()

          I tried using $$ifdef to check, not really expecting it to work because a subroutine is not a macro, and of course it didn't. Is there some equivalent for subroutines?

          Thanks.

          On 9/1/2010 3:10 PM, Support wrote:
           

          Actually, you can't pass macro calls to macros.

          The nesting referred to is macros calling other macros, to prevent infinite recursion of this sort::

          $$macro x()
          {{
              $$y()
          }}

          $$macro y()
          {{
              $$z()
          }}

          $$macro z()
          {{
              $$x()
          }}

          You might look into using @sub definitions for your filter rather than macros.

          On 9/1/2010 1:33 PM, xyzzy wrote:

          I'm trying to write a filter for HTML (for GURPS 3) that's a little more decorated than the default. I tried to put a macro expansion inside a macro expansion, like this:

          $$namevaluerow(Dodge:,$$showDodge(),name,value)

          It seems not to work. In particular, it makes Metacreator 4.1.1 crash, I'm guessing from some kind of overrun, since the crash takes several seconds.

          Here are the macro definitions:

          $$macro namevaluerow(name,value,nameClass,valueClass,test)
          {{
          $$ifdef(test)
          @assign _check = $(test)
          $$else
          @assign _check = 1
          $$endif
          @if _check
          <tr>
          <td$$ifdef(nameClass) class="$(nameClass)"$$endif>$(name)</td>
          <td$$ifdef(valueClass) class="$(valueClass)"$$endif>$(value)</td>
          </tr>
          @endif
          }}

          and

          $$macro showDodge(j){{%u_dodge%?u_dodge!=dodge?/%dodge%??}}

          Reference Manual p.232  (bottom) says macros may be nested to a depth of 10, so I'm assuming this works and I have made some sort of syntax error, but I can't figure out what it might be.

          By the way, this

          $$namevaluerow(Dodge:,%u_dodge%?u_dodge!=dodge?/%dodge%??,name,value)

          produces the expected behavior. The only difference is that I manually replaced $$showDodge() with its expansion.

        • Support
          Subroutine calls may not omit arguments.
          Message 4 of 5 , Sep 2, 2010
            Subroutine calls may not omit arguments.

            On 9/2/2010 2:04 PM, xyzzy wrote:
            Thanks for clearing the macro issue up.

            Can one omit arguments to filter subroutines defined by @sub, i.e. will the following work?

            @sub text(x,y)
            ...
            @endsub

            ...

            @text()

            I tried using $$ifdef to check, not really expecting it to work because a subroutine is not a macro, and of course it didn't. Is there some equivalent for subroutines?

            Thanks.

          Your message has been successfully submitted and would be delivered to recipients shortly.