; Peak Macro - This macro goes down a given column and determines the ; peak values and places the X and Y values in an output column. ; ; Clear all memory registers CM FIX 0 ; ; Input Dialog Box: alpha "X Input Column" STOa 0 0e+00 STO 00 alpha "Y Input Column" STOa 1 1 STO 01 alpha "Output Column for X Values" STOa 2 2 STO 02 alpha "Output Column for Y Peak Values" STOa 3 3 STO 03 alpha "Peak Macro" inpt 4 ; ; Storage Locations ; 00 - X Input Column ; 01 - Y Input Column ; 02 - X Output Column ; 03 - Y Output Column ; 04 - Number of rows in the data window ; 06 - Row and Column address of point 1 in decimal form ; 07 - Row and Column address of point 2 in decimal form ; 08 - Row and Column address of point 3 in decimal form ; 10 - Row and Column address of X destination data cell in decimal form ; 11 - Row and Column address of Y destination data cell in decimal form ; 12 - Row and Column address of X input value ; FIX 6 ibase size ; Determines the size of the data window STO 04 ; Stores the number of rows in 04 XEQ 50 ; Store address in decimal form, set row counter ; LBL 10 XEQ 30 RCLi 06 ; Recall the value of point 1 test 1 ; Test to see if the cell is empty GTO 60 test 2 ; Test to see if the cell contains masked data GTO 60 RCLi 07 ; Recall the value of point 2 test 1 ; Test to see if the cell is empty GTO 70 test 2 ; Test to see if the cell contains masked data GTO 70 RCLi 08 ; Recall the value of point 3 test 1 ; Test to see if the cell is empty GTO 80 test 2 ; Test to see if the cell contains masked data GTO 80 ; LBL 20 RCLi 06 ; Recall the value of point 1 RCLi 07 ; Recall the value of point 2 bool 2 ; Test if point 2 > point 1 RCLi 07 ; Recall the value of point 2 RCLi 08 ; Recall the value of point 3 bool 0 ; Test if point 3 < point 2 bool 7 ; Test if both boolean statements are true 0e+00 x < y ; Determine if the boolean AND is true or false XEQ 90 ; True - point 2 is a peak value GTO 60 ; False - point 2 is not a peak ; LBL 30 RCL 04 ; Recall the original # of rows 1 - RCL 08 ; Recall the current address int ; Get the integer portion of the address x = y ; Check to see if current address = # of rows STOP ; Yes - Stop RTN ; No - Read in next set of data ; LBL 50 RCL 01 ; Recall Y input column 1000 / ; Divide column by 1000 STO 06 ; Store column in decimal format 1 + STO 07 ; Give starting address for point 2 1 + STO 08 ; Give starting address for point 3 RTN ; LBL 60 1 ADD 06 ; Increase the point 1 address by 1 RCL 06 ; Recall point 1 address 1 + STO 07 ; Initialize the point 2 address 1 + STO 08 ; Initialize the point 3 address GTO 10 ; ; LBL 70 1 ADD 07 ; Increase the point 2 address by 1 1 ADD 08 ; Increase the point 3 address by 1 GTO 10 ; LBL 80 1 ADD 08 ; Increase the point 3 address by 1 GTO 10 ; LBL 90 RCL 00 ; Recall X input column 1000 / ; Divide column by 1000 STO 12 ; Store input address RCL 07 ; Recall current address of peak value int ; Determine current row of peak value ADD 12 ; Add current row to input address ; RCL 02 ; Recall X destination column 1000 / ; Divide column by 1000 STO 10 ; Store destination address RCL 07 ; Recall current address of peak value int ; Determine current row of peak value ADD 10 ; Add current row to destination column RCLi 12 ; Recall X value STOi 10 ; Store X value in output column ; RCL 03 ; Recall Y destination column 1000 / ; Divide column by 1000 STO 11 ; Store destination address RCL 07 ; Recall current address of peak value int ; Determine current row of peak value ADD 11 ; Add current row to destination column RCLi 07 ; Recall peak value STOi 11 ; Store peak value in output column RTN ; ; Version 2.0 - Apr. 5, 2006 ; by Steve Wilson