March 24, 200817 yr I would appreciate it if someone could tell me how to step through the repetitions of a repeating field like this Go To 1st Repetition Loop Set a value Go To Next Repetition, Exit after Last Repetition Exit Loop etc... Thanks
March 24, 200817 yr How about Set Variable [ $j; FieldRepetitions( Get ( FileName ); Get ( LayoutName ); "YourField" ) ] Set Variable [$i; 1 ] Loop Exit Loop If [ $i > $j ] Set Field [ YourField [$i]; "whatever"] Set Variable [$i; $i + 1 ] End Loop *** The Field with the number of repetitons you want filled out needs to be on the layout.
March 24, 200817 yr This will supposingly do: Go to Field [ Untitled::aFieldWithRep ] Loop ..... Go to Next Field Exit Loop If [ Get ( ActiveFieldName ) ≠ "aFieldWithRep" ] End Loop ...but shouldn't really be necessary, an easier way would to have the data in a relational structure and then make the repeating field be an unstored calc'field populated on demand, by a calc' like this: Let ( [ f = Extend ( PO_LineItems::Item ); g = GetNthRecord ( f ; Get (CalculationRepetitionNumber )) ]; If (g<>”?” ; g; “”)) ...to perform a task like as the one it originates from: http://fmcollective.com/2007/08/29/pseudoportals-with-alternating-fill/ Then is it done completely without any syncronization issues, since your normalization would have put your data in individual records anyway --sd
April 1, 200817 yr How about Set Variable [ $j; FieldRepetitions( Get ( FileName ); Get ( LayoutName ); "YourField" ) ] Set Variable [$i; 1 ] Loop Exit Loop If [ $i > $j ] Set Field [ YourField [$i]; "whatever"] Set Variable [$i; $i + 1 ] End Loop *** The Field with the number of repetitons you want filled out needs to be on the layout. Your script uses a set field statement. The field does NOT have to be on the layout.
April 1, 200817 yr Your script uses a set field statement. The field does NOT have to be on the layout. I beg to differ. The field DOES need to be on the layout in this instance since the script uses the FieldRepetitions function to set the number of reps to fill. Set Variable [ $j; FieldRepetitions( Get ( FileName ); Get ( LayoutName ); "YourField" ) The script step will not set with a value if the field is not on the layout.
April 1, 200817 yr The script step will not set with a value if the field is not on the layout. To avoid such problem, use: Set Variable [ $j; GetAsNumber ( FieldType ( Get ( FileName ) ; "repeatingField" ) ) ]
April 1, 200817 yr Hi Daniele, Yes I understand and agree, but the point of my sample was to Control how many reps that you want to fill by simply putting the field with the wanted reps on the layout (instead of an explicit parameter). *** The Field with the number of repetitons you want filled out needs to be on the layout That is why I specifically made the point with the asterisks to begin with. Edited April 1, 200817 yr by Guest rewording
April 1, 200817 yr I had nothing to say about your script The step I am talking about is only a suggestion to avoid the phisical presence of the field on the layout. If someone want to fill only some rep ( and not the MaxRepeat number of the field ) may set the variable to : GetAsNumber ( FieldType ( Get ( FileName ) ; "repeatingField" ) ) - "something" or Exit Loop If [ $i > $j -"something" ]
Create an account or sign in to comment