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

Re: [Clip] Re: Why does a neg value cause a syntax error in calc?

Expand Messages
  • loro
    ... Joy, I know this is old, but I was skimming through old post and started to play with this again and I discovered something useful. It s only when the
    Message 1 of 17 , Mar 1, 2011
    View Source
    • 0 Attachment
      joy8388608 wrote:
      >; Syntax error when first var is not initialized and second is negative
      >^!Set %JobAmt%=-10
      >^!Set %Temp4%=^$Calc(^%Cash16P% + ^%JobAmt%)$

      Joy, I know this is old, but I was skimming through old post and
      started to play with this again and I discovered something useful.
      It's only when the negative number is the first to be added to the
      not initiated variable the problem occurs.

      Try this.

      ^!Info ^$Calc(^%blah%+0+-5)$
      ===> -5

      So if you always add zero first, I think it should work.

      :-)
      Lotta
    • joy8388608
      ... Lotta - Thanks for going back and giving it more thought. I have, of course, already found a workaround, but this is a simpler and better one then I have
      Message 2 of 17 , Mar 2, 2011
      View Source
      • 0 Attachment
        --- In ntb-clips@yahoogroups.com, loro <tabbie@...> wrote:
        >
        > joy8388608 wrote:
        > >; Syntax error when first var is not initialized and second is negative
        > >^!Set %JobAmt%=-10
        > >^!Set %Temp4%=^$Calc(^%Cash16P% + ^%JobAmt%)$
        >
        > Joy, I know this is old, but I was skimming through old post and
        > started to play with this again and I discovered something useful.
        > It's only when the negative number is the first to be added to the
        > not initiated variable the problem occurs.
        >
        > Try this.
        >
        > ^!Info ^$Calc(^%blah%+0+-5)$
        > ===> -5
        >
        > So if you always add zero first, I think it should work.
        >
        > :-)
        > Lotta
        >
        Lotta -
        Thanks for going back and giving it more thought. I have, of course, already found a workaround, but this is a simpler and better one then I have and I will remember this technique for the future as will others.

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