! TITLE: ln_sel_end.mac (SELECTION) ! ! ! OBJECTIVE: ! ! This sub-macro returns the line number of the ith line attached to the ! keypoint nearest to the given x, y, z coordinates. ! ! COMMAND SYNTAX: ! ! (1) (2)(3)(4)(5) ! ln_sel_end, 'parm', x, y, z, i ! ! ! ARGUMENTS: ! ! parm = The resulting line number is assigned to the ! parameter name given by the quoted string given ! in the first argument. ! ! x,y,z = Coordinates relative to the active CS of a keypoint ! attached to the line of whose number it is desired. ! ! i = Starting from the lowest number line, return the number ! of the ith line attached to the keypoint nearest (x,y,z). ! Default = 1 ! ! ! DESCRIPTION: ! ! Ocassionaly it is difficult to obtain a line number by its midpoint ! location, and the location of an end point is more readily known and ! parameterized. This macro allows a line number to be obtained ! based one of its keypoints. ! ! If more than one line number is attached to the keypoint, the "i" ! parameter allows the ith line number to be obtained. The ith line ! is based on line number magnitudes. For example, say lines 20, 24 ! and 38 are attached to the keypoint, then for i = 2, line 24 would be ! returned. ! ! This macro is intended to be used when lines outside of a current macro ! block need to be referenced. The lm-xx method is not portable becasue ! moving macro blocks around alters the lines numbers. This method avoids ! that pitfall and allows line selection to be done without depending on a ! previous state of line numbering. The only time this method will fail is ! when the ordering of the lines connected to the keypoint is changed. ! ! *get,prkey_,active,0,prkey /nopr parm_=arg1 x_=arg2 y_=arg3 z_=arg4 i_=arg5 cm,kpset_,kp cm,lset_,line ksel,s,kp,,kp(x_,y_,z_) lslk,s,0 %parm_%=0 *do,ii_,1,i_ %parm_%=lsnext(%parm_%) *enddo ksel,s,kp,,kpset_ lsel,s,line,,lset_ *set,parm_ *set,x_ *set,y_ *set,x_ *set,i_ *set,ii_ *if,prkey_,eq,1,then /go *endif