{
    "header": {
        "version": 1,
        "type": "record"
    },
    "body": {
        "record1": {
            "<1>": "declare function msg, fieldcount, memberof, rds_comm, send_event, rds_comm2\r\ndeclare subroutine end_dialog, yield\r\n$insert logical\r\n$insert msg_equates\r\n$insert tw_info_array_equ\r\n$insert tw_codes_equ\r\n\r\nVoid = rds_comm( \"TW_ACCT_ROW_VAL\" )\r\n\r\ngosub CLEAN_INVALID_VALS\r\n\r\nRetVar = rds_comm2( 'TW_INSPEC_CHECK' )\r\nif RetVar then\r\n   * ERROR WILL DISPLAY IN THE CODE\r\n   return 0\r\nend\r\n\r\nTWQty = get_property( @window, '@TWQty', TWQty )\r\nNumTW = sum( .tw_info->array<1> )\r\nTWError = false$\r\nif NumTW = TWQty then\r\n   CurArray = .tw_info->array\r\n   NumRows = fieldcount( CurArray<1>, @vm ) +1 ;* JUST INCASE FIRST VALUE NULL\r\n   for i = 1 to NumRows\r\n      if CurArray<1,i> <> '' then\r\n         * check to see if they have entered a loss code for every\r\n         * row with rejects in it\r\n         if CurArray<2,i> <> '' else\r\n            TWError = true$\r\n         end\r\n         * NOW FORCE THEM TO ENTER NO MORE THAN 1 WAFER IF THIS REQUIRES DATA\r\n         * CAUSE WE WANT AN ENTRY FOR EACH AVERAGE NOT ONE AVERAGE FOR 5(EXAMPLE) WAFERS\r\n         CurCode = CurArray<TWInfoArrayCode$,i>\r\n         CurCnt  = CurArray<TWInfoArrayCnt$,i>\r\n         if xlate( 'TW_CODES', CurCode, tw_codes_run_data_required$, 'X' ) then\r\n            * MAKE SURE THE CNT IS NO MORE THAN ONE\r\n            if CurCnt = 1 else\r\n               TWError = true$\r\n            end\r\n         end\r\n      end else\r\n         if CurArray<2,i> = '' then\r\n            * blank line\r\n         end else\r\n            TWError = true$\r\n         end\r\n      end\r\n    until TWError\r\n   next i\r\n   if TWError then\r\n         MsgInfo = ''\r\n         MsgInfo<micon$> = 'H'\r\n         MsgInfo<mtext$> = 'You must enter test wafers and a usage code for every row that contains an entry!  Also, if the usage code requires data, you may only enter 1 wafer per line. i.e. ( we want the average for every wafer ).'\r\n         Void = msg( '', MsgInfo )\r\n      return 0\r\n   end else\r\n      CurArray = delete( CurArray, 3, 0, 0 ) ;* NEED TO DELETE THE THIRD COLUMN\r\n                                             ;* WHICH IS THE LOSS CODE DESCRIPTION\r\n                                             ;* THAT WE DON'T NEED TO STORE.\r\n      end_dialog( @window, CurArray )\r\n   end\r\nend else\r\n   MsgInfo = ''\r\n   MsgInfo<micon$> = 'H'\r\n   TWType = get_property( @window, '@TWType' )   \r\n   if NumTW > TWQty then\r\n      * entered too many rejects\r\n      Message = 'There are ':TWQty:' ':TWType:' test wafers and you have '\r\n      Message:= 'entered ':NumTW:', which is too many...Please fix this problem.'\r\n   end else\r\n      * didn't enter enough rejects\r\n      Message = 'There are ':TWQty:' ':TWType:' test wafers and you have '\r\n      Message:= 'only entered ':NumTW:'...Please account for all test wafers.'\r\n   end\r\n   MsgInfo<mtext$> = Message\r\n   Void = msg( '', MsgInfo )\r\nend\r\nRETURN 0\r\n*===============================================================================================*\r\nCLEAN_INVALID_VALS:\r\n   ValidArray = get_property( @window, '@ValidArray', ValidArray )\r\n   CurArray = .tw_info->array\r\n   Rcnt = fieldcount( CurArray<1>, @vm )\r\n   for i = 1 to Rcnt\r\n      for j = TWInfoArrayThick$ to TWInfoArrayRHO$\r\n         if ( ValidArray<i,j> = 1 ) then\r\n            CurArray<j,i> = ''\r\n         end\r\n      next j\r\n   next i\r\n   .tw_info->array = CurArray\r\nreturn\r\n*===============================================================================================*"
        }
    }
}