INIT: length mode val cmd $ 8 row 8 string $ 200 keyfield $ 8 ftype $ 8 fform $ 32; call notify('.','_get_widget_','TABLE',tableid); dsid=open('sasuser.class'); call set(dsid); control always; row=1; txtflds=0; foundit=0; return; MAIN: cmd=word(1,'u'); val=word(2); select(cmd); when('KEYFIELD') mode='KEYFIELD'; link keyfield; call nextcmd(); when('FIND') mode ='FIND'; link find; call nextcmd(); when('FORWARD') call send(tableid,'_vscroll_','page',1); call nextcmd(); when('BACKWARD') call send(tableid,'_vscroll_','page',-1); call nextcmd(); when('TOP') call send(tableid,'_vscroll_','max',-1); call nextcmd(); when('BOTTOM') call send(tableid,'_vscroll_','max',1); call nextcmd(); otherwise; end; return; TERM: rc=close(dsid); rc=dellist(txtflds,'y'); return; GET1: if fetchobs(dsid,_currow_)=-1 then do; mode=''; call send(tableid,'_endtable_'); end; if txtflds=0 then do; txtflds=makelist(); call send(tableid,'_get_widgets_',listid); do i=2 to listlen(listid); sublist=getiteml(listid,i); call send(sublist,'_IS_A_', 'SASHELP.FSP.EFIELD',istextentry); if istextentry then rc=insertc(txtflds,getnitemc(sublist,'FTYPE')||':' ||getnitemc(sublist,'FORMAT'),-1, getnitemc(sublist,'NAME') ); end; end; if mode='FIND' then do; call notify('.','_get_widget_',keyfield,id); ftype=getnitemc(id,'FTYPE',1); if ftype='CHAR' then do; call notify(keyfield,'_get_text_',string); string=trim(left(putc(string,fform))); end; else if ftype in ('NUM','SHORT','FIXED') then do; call notify(keyfield,'_get_value_',number); string=trim(left(putn(number,fform))); end; foundit=(string=val); if foundit then do; row=_currow_; mode=''; end; end; return; KEYFIELD: if val ne ' ' then do; ftype=getnitemc(txtflds,val,1,1,' '); if ftype ne ' ' then do; fform=scan(ftype,2,':'); ftype=scan(ftype,1,':'); keyfield=val; if fform=' ' then do; if ftype='CHAR' then fform='$200.'; else fform='best12.'; end; _msg_='NOTE: The current keyfield is '||upcase(keyfield); end; else _msg_='ERROR: Unknown alias (name) for current screen.'; end; else do; if keyfield=' ' then _msg_='ERROR: Invalid field name, '|| 'please enter KEYFIELD command again.'; else _msg_='NOTE: The current keyfield is '||upcase(keyfield); end; return; STOPIT: mode=''; _msg_='Attention was issued. The FIND command ceased execution.'; return; FIND: control break stopit; if keyfield=' ' then do; _msg_='ERROR: You must first issue KEYFIELD FIELDNAME.'; mode=''; return; end; If ^foundit then do; call send(tableid,'_set_toprow_',1); call send(tableid,'_get_toprow_',toprow); mode='FIND'; foundit=0; call send(tableid,'_refresh_'); do while(mode='FIND'); call send(tableid,'_vscroll_','page',1); call send(tableid,'_refresh_'); end; end; call send(tableid,'_set_toprow_',row); if ^foundit then _msg_='WARNING: No occurrences of "'||val||'" found.'; foundit=0; return;