Hello all,
I am trying to use the indexed-repeat function to return a value from a repeat when PASS/FAIL-oriented repeat's own index isn't 1. The context for this is that I am working with calculated values that correspond to specific structure heights, so for the span between the first elevation measurement and the ground, I need a zero in the math.
This is the snippet of what I am working with, consisting of rows from A (type) to S (bind::type):
| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S |
| begin repeat | pt_passfail_s | <h3>Pass/Fail By Guy Level</h3> | | | compact | | | | | | | | | | | | | |
| integer | condition_index | Get repeat index of this condition assessment | | | hidden | | | | | position(..) | | | | | | | | |
| integer | condition_index_m1 | Subtract 1 from condition index | | | hidden | | | | | ${condition_index}-1 | | | | | | | | |
| calculate | lower_elevation | Lower elevation: | | | | | | | | if(${condition_index}=1,0,indexed-repeat(${pt_guy_level_height}, ${guy_elevations_s}, ${condition_index_m1})) | | | | | | | | integer |
| calculate | upper_elevation | Upper elevation: | | | | | | | | indexed-repeat(${pt_guy_level_height}, ${guy_elevations_s}, ${condition_index}) | | | | | | | | integer |
| calculate | distance_between | Calculate distance between elevations | | | | | | | | ${upper_elevation} - ${lower_elevation} | | | | | | | | integer |
| note | | Distance between elevations ${condition_index} (${lower_elevation}') and ${condition_index_m1} (${upper_elevation}'): ${distance_between} | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | |
| calculate | lower_twist | Lower twist: | | | | | | | | if(${condition_index}=1,0,indexed-repeat(${pt_calcs_twist_alpha}, ${pt_calcs_s}, ${condition_index_m1})) | | | | | | | | decimal |
| calculate | upper_twist | Upper twist: | | | | | | | | indexed-repeat(${pt_calcs_twist_alpha}, ${pt_calcs_s}, ${condition_index}) | | | | | | | | decimal |
| calculate | twist_between | Calculate twist between elevations | | | | | | | | ${upper_twist} - ${lower_twist} | | | | | | | | decimal |
| calculate | twist_per_ten | Get divisor for twist per ten feet and compute degrees twist per ten feet | | | | | | | | (${twist_between} div (${distance_between} div 10)) | | | | | | | | decimal |
| note | | Twist between elevations ${condition_index} (${lower_twist}˚ at ${lower_elevation}') and ${condition_index_m1} (${upper_twist}˚ at ${upper_elevation}'): ${twist_between}˚ | | | | | | | | | | | | | | | | |
| note | | Average twist per ten feet between elevations ${condition_index} and ${condition_index_m1}: ${twist_per_ten}˚ | | | | | | | | | | | | | | | | |
| note | | <b>FAIL: EXCEEDS 0.5˚ TWIST / 10'!</b> | | | | | | | | | | | ${twist_per_ten} > 0.5 | | | | | |
| note | | <b>PASS!</b> | | | | | | | | | | | ${twist_per_ten} <= 0.5 | | | | | |
| | | | | | | | | | | | | | | | | | | |
| calculate | lower_plumb | Lower plumb: | | | | | | | | if(${condition_index}=1,0,indexed-repeat(${pt_calcs_plumb_r}, ${pt_calcs_s}, ${condition_index_m1})) | | | | | | | | decimal |
| calculate | upper_plumb | Upper plumb: | | | | | | | | indexed-repeat(${pt_calcs_plumb_r}, ${pt_calcs_s}, ${condition_index}) | | | | | | | | decimal |
| calculate | plumb_between | Calculate plumb between elevations | | | | | | | | ${upper_plumb} - ${lower_plumb} | | | | | | | | decimal |
| note | | Plumb between elevations ${condition_index} (${lower_plumb}" at ${lower_elevation}')and ${condition_index_m1} (${upper_plumb}" at ${upper_elevation}'): ${plumb_between}" | | | | | | | | | | | | | | | | |
| note | | <b>FAIL: OUT-OF-PLUMBNESS EXCEEDS 0.25% OF ${distance_between}'!</b> | | | | | | | | | | | ${plumb_between} > (${distance_between} div 400) | | | | | |
| note | | <b>PASS!</b> | | | | | | | | | | | ${plumb_between} <= (${distance_between} div 400) | | | | | |
| | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | |
| end repeat | pt_passfail_s | | | | | | | | | | | | | | | | | |
This code causes a TypeError for all of my lower_<quantity> terms, and I am not sure why. I believe my if() functions in those rows are constructed correctly, and I have triple-checked that those rows have their bind::type column set to integer. Basically, if the pass/fail repeat is displaying the first record, lower_<quantity> needs to be 0 in each case. On every successive record, it needs to be the value that was upper_<quantity> in the previous record. I thought I accounted for this with my condition_index and condition_index_m1 rows.
I've never tried using the indexed-repeat() function as the "else" component of an if() function, but I don't see why it wouldn't work. Am I missing something about the data type returned by ndexed-repeat()?
Any thoughts or solutions would be greatly appreciated. Thanks!
P.S. These cells are coming from a "recipe book" I keep for modular survey-building. Therefore I can't really post the XLS file here because there would be a pretty significant amount of stuff irrelevant to this particular issue, but I can come up with something in DMs if you are willing to help!