Select to view content in your preferred language

Using indexed-repeat in an if() function

1110
2
Jump to solution
09-06-2023 05:34 PM
MattEdrich
Frequent Contributor

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):

ABCDEFGHIJKLMNOPQRS
begin repeatpt_passfail_s<h3>Pass/Fail By Guy Level</h3>  compact             
integercondition_indexGet repeat index of this condition assessment  hidden    position(..)        
integercondition_index_m1Subtract 1 from condition index  hidden    ${condition_index}-1        
calculatelower_elevationLower elevation:       if(${condition_index}=1,0,indexed-repeat(${pt_guy_level_height}, ${guy_elevations_s}, ${condition_index_m1}))       integer
calculateupper_elevationUpper elevation:       indexed-repeat(${pt_guy_level_height}, ${guy_elevations_s}, ${condition_index})       integer
calculatedistance_betweenCalculate distance between elevations       ${upper_elevation} - ${lower_elevation}       integer
note Distance between elevations ${condition_index} (${lower_elevation}') and ${condition_index_m1} (${upper_elevation}'): ${distance_between}                
                   
calculatelower_twistLower twist:       if(${condition_index}=1,0,indexed-repeat(${pt_calcs_twist_alpha}, ${pt_calcs_s}, ${condition_index_m1}))       decimal
calculateupper_twistUpper twist:       indexed-repeat(${pt_calcs_twist_alpha}, ${pt_calcs_s}, ${condition_index})       decimal
calculatetwist_betweenCalculate twist between elevations       ${upper_twist} - ${lower_twist}       decimal
calculatetwist_per_tenGet 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     
                   
calculatelower_plumbLower plumb:       if(${condition_index}=1,0,indexed-repeat(${pt_calcs_plumb_r}, ${pt_calcs_s}, ${condition_index_m1}))       decimal
calculateupper_plumbUpper plumb:       indexed-repeat(${pt_calcs_plumb_r}, ${pt_calcs_s}, ${condition_index})       decimal
calculateplumb_betweenCalculate 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 repeatpt_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!

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

Why are your bind::type values integer when it should be int.  There should be a drop down with those options.  You can also now use integer as the type and a hidden appearance.

I am also wondering if it will get mad on the first record since then condition_index_m1 would give a negative value?

In your indexed repeat your ask for a field ${pt_guy_level_height} but I do not see it in this list at all?  Where is this field?

Just some ideas

 

View solution in original post

2 Replies
DougBrowning
MVP Esteemed Contributor

Why are your bind::type values integer when it should be int.  There should be a drop down with those options.  You can also now use integer as the type and a hidden appearance.

I am also wondering if it will get mad on the first record since then condition_index_m1 would give a negative value?

In your indexed repeat your ask for a field ${pt_guy_level_height} but I do not see it in this list at all?  Where is this field?

Just some ideas

 

MattEdrich
Frequent Contributor

Ahh Doug, brilliant as always! The main issue was indeed my use of integer instead of int, silly me. You were also apparently correct about an issue occurring with the first record, though no obvious error was caused; instead, no values were populating. I was able to get around this by finagling some of the calculation expressions, as in the following example:

ABCDEFGHIJKLMNOPQRS
calculatelower_elevationLower elevation:       indexed-repeat(${pt_guy_level_height}, ${guy_elevations_s}, ${condition_index_m1})  ${condition_index}>1    int
calculateupper_elevationUpper elevation:       indexed-repeat(${pt_guy_level_height}, ${guy_elevations_s}, ${condition_index})       int
calculatedistance_betweenCalculate distance between elevations       if(${condition_index}>1,(${upper_elevation}-${lower_elevation}),${upper_elevation})       int

 

Finally, the ${pt_guy_level_height} field lives up in a repeat that happens several hundred rows higher in my 'Recipe' XLS form, as it applies to a variety of my survey modules - hence why it wasn't included here.

Thanks again for the solid eyeballs and suggestions!