Matlab 版 (精华区)

发信人: ramjet (史努比狗), 信区: Matlab
标  题: sourcecode: a wait bar
发信站: 哈工大紫丁香 (2002年02月26日21:48:13 星期二), 站内信件

一个很有趣的小程序,今天在网上看到的,
可是实现倒计时的功能。

%<<CODE BEG>>>
% note
% <tlen> accumulates the
% total amount of text + 1<CR/LF>
% for each line that you want to erase + 1 for itself


% create some text
        disp(sprintf('\n\n\demo: loop-indicator\n\n\n'));
        z=char(8);
for i=1:10
        txt=sprintf('looping %5d %s',i,repmat('.',1,i));
        tlen=length(txt)+1;
        disp(txt);
% do <something>
        txt=sprintf('working on item %5d %g',i,pi*(i+rand));
        tlen=tlen+length(txt)+1;
        disp(txt);
        pause(.5)
% clean 
        disp(repmat(z,1,tlen+1));
end
        disp('done');
%<<<CODE END>>>

              在这个时代
              如果你要为社会做一点贡献的话
              那么就想办法
              让你和你爱的人
              好好的活着

※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.237.3]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.290毫秒