SAS中文论坛

标题: 急救!! [打印本页]

作者: shiyiming    时间: 2005-1-11 16:18
标题: 急救!!
我的注册界面突然出了问题用不了了
代码如下:
reg:                                                                                                                                                
                                                                                                                                                      
   if username.text ne '' and userpwd.text ne '' and repwd.text ne '' then do;                                                                        
                                                                                                                                                      
    if regtype.selectedIndex=1 then do;                                                                                                               
       id=open('sasdata.Admregtbl','us');                                                                                                            
        nobs= attrn(id,'nobs');                                                                                                                       
        flag='0';                                                                                                                                    
          do i=1 to nobs;                                                                                                                             
               rc=fetchobs(id,i);                                                                                                                     
                 name=getvarc(id,1);                                                                                                                  
               if name=username.text then do;                                                                                                         
                      flag='1';                                                                                                                       
                       _msg_='该用户已经存在,请注册新的用户名';                                                                                       
                      /* username.text='';*/                                                                                                         
                       userpwd.text='';                                                                                                               
                       repwd.text='';                                                                                                                 
                      end;                                                                                                                           
               end;
第一次执行时可以通过,从第二次开始便提示错误:
ERROR: 没有执行请求的函数是因为 SASDATA.OPRREGTBL 上没有当前的记录。可能最后一次读取失败了。
Arguments passed to GETVARC:
  1 id = 1
  2 (Numeric Literal) = 1
这到底是怎么回事呢?
另外,师兄们有没有更好的解决项数据集里插入新记录的方式呢?而且必须是不通过同名变量传递变量值的方式。
作者: shiyiming    时间: 2005-1-11 18:10
标题: to shenjuju
试试看
[color=red:08618]nobs= attrn(id,'NLOBSF');[/color:08618]

我一般在SCL里用
[code:08618]submit continue;
proc print noprint;
insert into ......;
quit;
endsubmit;[/code:08618]
的方式。
作者: shiyiming    时间: 2005-1-11 22:00
标题: hihi
对于这种无聊的人,我还是要帮帮的,省得太寂寞了!

以下是自己曾经写的玩的入门级的登陆代码,仅可以学习,不可以做工业用途。

[code:5ca9b]Entry user:u:pgm.admin.user.class
      pass:u:num;

INIT:
   import pgm.comm.comm.class;
   dcl comm comm = _new_ comm();

   dcl num rc;
return;

txt_user:
   cursor txt_pwd;
return;

txt_pwd:
   link btn_ok;
return;

*确定按钮;
btn_ok:
   if txt_user.text="" then do;
      comm.warn({'请输入用户名'});return;
   end;
   if txt_pwd.text="" then do;
      comm.warn({'请输入密码'});return;
   end;

   user.uname    = txt_user.text;
   user.password = txt_pwd.text;


   rc=user.chkUserInfo(user);
   if rc^=0 then do;
      if rc=-1 then comm.warn({'该用户名不存在'});
      else if rc =-2 then do;
         comm.warn({'密码输入错误'});
         txt_pwd.text="";
      end;
      else comm.warn({'系统错误'});
      pass=0;
   end;else do; *用户及密码合法;
      rc=user.getUserInfo(user.uname,user);
      if rc^=0 then do;
         pass=0;
         comm.warn({'系统错误-获取用户信息'});
         call execcmd('end');
         return;
      end;

      pass=1;
      call execcmd('end');
   end;
return;

*取消按钮;
btn_cancel:
   pass=-1;
   call execcmd('end');
return;

MAIN:

return;

TERM:
   if _status_='E' and pass ^=1 then do;
      rc = comm.showYN({'确认退出系统'});
      if rc = 0 then do;
         _status_='R';
         return;
      end;else do;
         pass=-1;
         call execcmd('end');
      end;
   end;

   comm._term();
return;[/code:5ca9b]
作者: shiyiming    时间: 2005-1-12 11:41
标题: :(
尽管被鄙视成无聊的人,但还是要谢谢两位师兄!
<!-- s:cry: --><img src="{SMILIES_PATH}/icon_cry.gif" alt=":cry:" title="Crying or Very sad" /><!-- s:cry: --> 哎,真是伤心!




欢迎光临 SAS中文论坛 (http://mysas.net/forum/) Powered by Discuz! X3.2