/* Source Code for obswww11 */ /*******************************************************************************/ /*******************************************************************************/ /* Model's SCL for Example 1 */ length highlight $7 foreground $5 ; INIT: /* Model's INIT SCL */ if variance le -50 then do; /* Highlighting for LE -50 */ highlight = 'ORANGE'; foreground = 'WHITE'; end; /* Highlighting for LE -50 */ else if variance le -25 then do; /* Highlighting for -49 to -25 */ highlight = 'YELLOW'; foreground = ‘BLACK'; end; /* Highlighting for -49 to -25 */ else if variance le 25 then do; /* Highlighting for -24 to 25 */ /* BACKGROUND is a keyword for the default background color */ highlight = 'BACKGROUND'; foreground = 'BLACK'; end; /* Highlighting for -24 to 25 */ else if variance le 50 then do; /* Highlighting for 26 to 50 */ highlight = 'CYAN'; foreground = 'BLACK'; end; /* Highlighting for 26 to 50 */ else do; /* Highlighting for GT 50 */ highlight = 'MAGENTA'; foreground = 'WHITE'; end; /* Highlighting for GT 50 */ /*****************************************/ /* Apply the highlight and text color */ /*****************************************/ call send(_viewer_,'_SET_VIEWER_ATTRIBUTE_','VARIANCE', 'BCOLOR',highlight); call send(_viewer_,'_SET_VIEWER_ATTRIBUTE_','VARIANCE', 'FCOLOR',foreground); return; /* Model's INIT SCL */ /*******************************************************************************/ /* Model's SCL entry for Example 2 */ length col_val $16 column $8 highlight $10 text $10 ; INIT: /* Model's SCL INIT */ /**************************************/ /* Highlight only the VARIANCE row */ /**************************************/ if _NAME_ = 'VARIANCE' then do; /* Determine the row to highlight */ colnames = makelist(); call send(_self_,'_GET_DISPLAYED_COLUMNS_',colnames); /**************************************/ /* Highlight each column in this row */ /**************************************/ do i=1 to listlen(colnames); /**************************/ /* Determine column name */ /**************************/ column = getitemc(colnames,i); call send(_self_,'_GET_COLUMN_TEXT_',column,col_val); col_val = compress(col_val); /*******************************/ /* Set the highlighting colors */ /*******************************/ if col_val = 'VARIANCE' then do; /* No Highlight for Row Labels */ highlight = 'BACKGROUND'; text = 'FOREGROUND'; end; /* No Highlight for Row Labels */ else if col_val gt '50' then do; /* Highlight for GT 50 */ highlight = 'ORANGE'; text = 'WHITE'; end; /* Highlight for GT 50 */ else if col_val gt '20' then do; /* Highlight for 21 to 50 */ highlight = 'YELLOW'; text = 'BLACK'; end; /* Highlight for 21 to 50 */ else do; /* Highlight for LT 21 */ highlight = 'GREEN'; text = 'WHITE'; end; /* Highlight for LT 21 */ /***********************************/ /* Set the cell's highlight color */ /***********************************/ call send(_viewer_,'_SET_VIEWER_ATTRIBUTE_',column, 'BCOLOR',highlight); /***********************************/ /* Set the cell's text color */ /***********************************/ call send(_viewer_,' _SET_VIEWER_ATTRIBUTE_',column, 'FCOLOR',text); end; /* do i=1 to attrn(dsid,'NVARS') */ /***********************************/ /* Clean Up */ /***********************************/ if colnames then colnames = dellist(colnames); rc = rc; end; /* If _NAME_='VARIANCE' */ return; /* Model's SCL INIT */ /*******************************************************************************/ /* Frame's SCL for Example 3 */ length colname $8 color $16; INIT: /* Frame's INIT */ call notify('.','_GET_WIDGET_','TABLE',t_id); call send(t_id,'_SET_DATASET_','SASHELP.IAWFIN'); return; /* Frame's INIT */ TABLE: /*****************************************/ /* Highlight/Unhighlight Select Column */ /*****************************************/ lsidrow=makelist(); /* Selected Row */ lsidcol=makelist(); /* Selected Column */ /*************************************/ /* Get the selected column number */ /*************************************/ call send(t_id,'_GET_ACTIVE_CELL_',lsidrow,lsidcol); col = getitemn(lsidcol,1); /*************************************/ /* Get the selected column name */ /*************************************/ call send(t_id,'_GET_DISPLAYED_COLUMN_NAME_',col,colname); /*************************************/ /* Get the current column color */ /*************************************/ call send(t_id,'_GET_COLUMN_ATTRIBUTE_',colname,'DBCOLOR',color); /**************************************/ /* Toggle the highlight color */ /**************************************/ select(color); when('BACKGROUND') color='YELLOW'; otherwise color = 'BACKGROUND'; end; /* Select Color */ /***************************************/ /* Apply the selected column highlight */ /***************************************/ call send(t_id, '_SET_COLUMN_ATTRIBUTE_', colname,'DBCOLOR',color); /*******************************************/ /* Clean up */ /*******************************************/ if lsidrow then lsidrow=dellist(lsidrow); if lsidcol then lsidcol=dellist(lsidcol); /*******************************************/ /* Force a refresh of the model/viewer */ /*******************************************/ call send(t_id,'_UPDATE_'); return; /* TABLE */ /*******************************************************************************/ /* Frame's SCL for Example 4 */ INIT: call notify('.','_GET_WIDGET_','TABLE',t_id); lsidlocl = envlist('L'); lsidsel = makelist(); lsidlocl = insertl(lsidlocl,lsidsel,-1,'Sel_Rows'); return; /* Frame's INIT */ TABLE: /* Data Table Widget */ /******************************************/ /* Determine the selected row */ /******************************************/ lsidrow = makelist(); lsidcol = makelist(); call send(t_id,'_GET_ACTIVE_CELL_',lsidrow,lsidcol); row = getitemn(lsidrow,1); /*******************************************/ /* Check if the row had been selected */ /* earlier, remove it if so, add it if not */ /*******************************************/ selected = searchn(lsidsel,row); if selected then lsidsel = delitem(lsidsel, selected); else lsidsel = insertn(lsidsel,row); /*******************************************/ /* Remove the box around the cell, */ /* Refresh the data table */ /*******************************************/ call send(t_id,'_CLEAR_ACTIVE_CELL_'); /********************************************/ /* Clean up */ /********************************************/ if lsidrow then lsidrow = dellist(lsidrow); if lsidcol then lsidcol = dellist(lsidcol); return; /* TABLE */ TERM: if lsidsel then lsidsel = dellist(lsidsel); return; /* TERM */ /*******************************************************************************/ /* Model's SCL for Example 4 */ INIT: /* Model's INIT section */ /*******************************************/ /* Get the list of selected rows from the */ /* local environment list */ /*******************************************/ if lsidlocl = . then do; /* List has not been retrieved */ lsidlocl = envlist('L'); lsidsel = getniteml(lsidlocl,'Sel_Rows'); end; /* List has not been retrieved */ /*******************************************/ /* Determine the current row number */ /*******************************************/ call send(_viewer_,'_GET_CURRENT_ROW_NUMBER_',currow); /*******************************************/ /* Check if this row has been selected */ /* if so, highlight, else remove highlight */ /*******************************************/ selected = searchn(lsidsel,currow); if selected then call send(_viewer_,'_SET_VIEWER_ATTRIBUTE_','_ALL_', 'BCOLOR','YELLOW'); else call send(_viewer_,'_SET_VIEWER_ATTRIBUTE_','_ALL_', 'BCOLOR','BACKGROUND'); return; /* Model's SCL INIT */ /*******************************************************************************/ /* Frame's SCL for Example 5 */ length colname $8; INIT: /*************************************************/ /* Determine the id of the Data Table Object */ /*************************************************/ call notify('.','_GET_WIDGET_','TABLE',t_id); /*************************************************/ /* Create the parent list for the selected rows */ /* and insert it into the local environment list */ /*************************************************/ lsidlocl = envlist('L'); lsidrows = makelist(); lsidlocl = insertl(lsidlocl,lsidrows,-1,'Sel_Rows'); return; TABLE: /* Data Table Object */ /*************************************************/ /* Initiate work lists for row and column ids */ /*************************************************/ lsidrow = makelist(); lsidcol = makelist(); /*************************************************/ /* Determine the selected cell address */ /*************************************************/ call send(t_id,'_GET_ACTIVE_CELL_',lsidrow,lsidcol); col = getitemn(lsidcol,1); row = getitemn(lsidrow,1); /************************************************/ /* Retrieve the selected column name */ /************************************************/ call send(t_id,'_GET_DISPLAYED_COLUMN_NAME_',col,colname); /************************************************/ /* Determine if the cell has been previously */ /* selected by checking the row (a named */ /* item in the list LSIDROWS) and then the */ /* column name (in the row sublist) */ /************************************************/ if nameditem(lsidrows,quote(put(row,3.))) then do; /* Row previously selected */ /*****************************************/ /* Manage the deselecting of the last */ /* selected column in the current row */ /*****************************************/ /*****************************************/ /* Get the list for the current row */ /*****************************************/ lsidprow = getniteml(lsidrows,quote(put(row,3.))); /******************************************/ /* If the current column is the only one */ /* in this sublist, delete the sublist */ /******************************************/ if listlen(lsidprow) eq 1 and colname = getitemc(lsidprow) then do; /* Deselected the last column */ lsidprow = dellist(lsidprow); lsidrows = delnitem(lsidrows,quote(put(row,3.))); end; /* Deselect the last column */ else do; /* Column Names in the sublist */ /*************************************/ /* If the current column name is in */ /* the sublist, remove it. Otherwise */ /* add it to the sublist */ /*************************************/ p_col = searchc(lsidprow,colname); if p_col then lsidprow = delitem(lsidprow,p_col); else lsidprow = insertc(lsidprow,colname); end; /* Column Names in the sublist */ end; /* Row previously selected */ /********************************************/ /* For new row selections, create a sublist */ /* name it the current row number, and */ /* insert the name of the current column */ /********************************************/ else do; /* New Row selection */ lsidprow = makelist(); lsidrows = insertl(lsidrows,lsidprow,-1,quote(put(row,3.))); lsidprow = insertc(lsidprow,colname); end; /* New Row Selection */ /*****************************************/ /* Remove the box around the cell, */ /* Refresh the data table */ /*****************************************/ call send(t_id,'_CLEAR_ACTIVE_CELL_'); /*****************************************/ /* Clean up */ /*****************************************/ if lsidrow then lsidrow = dellist(lsidrow); if lsidcol then lsidcol = dellist(lsidcol); return; /* TABLE */ TERM: if lsidrows then lsidrows = dellist(lsidrows,'Y'); lsidlocl = delnitem(lsidlocl,'Sel_Rows'); return; /* TERM */ /*******************************************************************************/ /* Model's SCL for Example 5 */ INIT: /******************************************/ /* Get the list of selected rows from the */ /* local environment list */ /******************************************/ if lsidlocl = . then do; /* Local Environment List Missing */ lsidlocl = envlist('L'); lsidrows = getniteml(lsidlocl,'Sel_Rows'); end; /* Local Environment List Missing */ /******************************************/ /* Determine the current row number */ /******************************************/ call send(_viewer_,'_GET_CURRENT_ROW_NUMBER_',currow); /********************************************/ /* Check if the current row has selected */ /* columns in it */ /********************************************/ sel_row = nameditem(lsidrows,quote(put(currow,3.))); /********************************************/ /* Highlight the selected columns in the */ /* current row */ /********************************************/ if sel_row then do; /* Col(s) in this row were selected */ /***************************************/ /* Get the list of selected columns */ /****************************************/ lsidrow = getiteml(lsidrows,sel_row); /***************************************/ /* Highlight each selected column */ /***************************************/ do i = 1 to listlen(lsidrow); /************************************/ /* Get the name of the column */ /************************************/ curcol = getitemc(lsidrow,i); /*************************************/ /* Apply the highlighting */ /*************************************/ call send(_viewer_,'_SET_VIEWER_ATTRIBUTE_',curcol, 'BCOLOR','YELLOW'); end; /* do i = 1 to listlen(lsidrow) */ end; /* Col(s) in this row were selected */ /**********************************************/ /* Apply the default background color to the */ /* unselected cells */ /**********************************************/ else call send(_viewer_,'_SET_VIEWER_ATTRIBUTE_','_ALL_', 'BCOLOR','BACKGROUND'); return; /* Model's INIT */ /*******************************************************************************/