pb_add.m

来自「这是机械工业张德丰《MATLAB与外部程序接口编程》随书源码」· M 代码 · 共 22 行

M
22
字号
%添加电话簿
function pb_add(pb_htable)
disp 'Type the name for the new entry, followed by Enter.'
disp 'Then,type the phone number(s), one per line.'
disp 'To complete the entry, type an extra Enter.'
name=input('::', 's');
entry=[name '^'];
while 1
    line=input('::','s');
    if isempty(line)
        break;
    else
        entry=[entry line '^'];
    end;
end;
if strcmp(entry, '^')
    disp 'No name entered'
    return;
end;
pb_htable.put(pb_keyfilter(name), entry);
disp ''
disp(sprintf('%s has been added to the phone book.', name));

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?