variables loose value

Hi,
after unsuccessful ties to do some maths I fear either to do something wrong or to find a bug. It seems variables loose their value after display.

AT: {$val_kw=if($val_at_mod > 0, $val_at+6+floor($val_at_mod), $val_at+6)}, PA: {$val_kw} - {$val_kw_half={val_kw / 2}} {$val_pa={ceil($val_kw_half)}}

This is a quite complex calculation (for my NPC-Generator :) ) for the attack- and parade-value (for the roleplaying game "the dark eye"). "$val_kw" is correctly calculated and displayed, but if I try to use it for another calculation its value is "0". I only display the " {$val_kw} - " because I feared that the value changed, what wouldn't be correct.

Someone with a hint?

Thx WarFred

PS: the calculation at itself isn't the problem and there is no need to understand (but I could they explain, if desired ;) )!

Comments

  • A screenshot for better understanding.

  • edited June 2018

    It seems I could solve the Problem by myself:

        AT: {$val_kw=[@calc_kw]}, PA: {$val_pa=[@calc_kw_half]} 
        MaxReps: 100
        EndTable:
    
        Table: calc_kw
        if($val_at_mod > 0, $val_at+6+floor($val_at_mod), $val_at+6)
        EndTable:
    
        Table: calc_kw_half
        {ceil([@calc_kw]/2)}
        EndTable:
    

    I simply stored the calculations in extra tables and now it works.
    But I still don't know, if Variables loose their value after display or not. :(

  • I used the syntax {@var} in the PA calculation to retrieve the stored values of val_kw and it worked. Here's the test code:

    ; variable value.ipt
    ; created 6/3/2018 11:02:08 AM
    Set: val_at = 4
    Set: val_at_mod = 1.2
    Table: Value
    AT {@val_kw = if({val_at_mod} > 0, {val_at}+6+floor({val_at_mod}), {val_at}+6)}, PA: {@val_kw} - {@val_kw_half=({@val_kw} / 2)} {@val_pa={ceil({@val_kw_half})}}
    

    Here's the output:

  • Thx for your help, but I decided to change from IPP3 to a "real" programming language, since I tried this night for about 4 hours (I went to bed at 5.15 am!) some complex calculations and failed. :(
    IPP3 is very mighty, but lack of a lot of comfort functions (e.g. conditions like "and", "or", "xor" and nested "when"-conditions).

  • No problem. My main issue is always that I really don't have a decent grasp on the difference between {var} & {@var} and [@var] and [var], etc. I generally have to try all versions of syntax (and more) before I get the expected output. It's all probably there in the help file, but I just don't get it.

    But, I do love the integrated html output window. No difficult programming to define the graphic output, etc. Now, there may well be "modern" programming languages that do the same (or better), but I haven't used a "real" programming language since Cobal, Pascal, and VB about 25 years ago (I can hack my through a bit of SQL and Crystal, but not enough to be proficient). Agree IPP is not the most powerful with built-in functions, but its mostly intuitive and sure beats creating volumes of d100 tables to manually roll on for results. Plus, its FREE!

    Good luck!

Leave a Comment