📄 savebase.m
字号:
%
% Syntax: savebase(strBaseFile, RuleBase)
%
% Inputs: strBaseFile is a string containing a filename.
% RuleBase is the RuleBase to be saved
%
% Result: The rule base that is currently being edited is saved to the file
% specified by strBaseFile (either 'cartbase.txt' or 'ballbase.txt').
%
% Petur Snaeland, 30.04.1995.
% Revised Hordur Kvaran, 20.10.97
%
function savebase(strBaseFile, RuleBase)
%
% Open the text file containing the appropriate rulebase.
%
%eval([ 'hBaseFile = fopen(''' strBaseFile ''',''r+t'');' ]);
[hBaseFile,errormessage] = fopen(strBaseFile,'r+t');
if (hBaseFile==-1),
filepath=which(strBaseFile);
if isempty(filepath),
doevent('MainExit');
error(strcat(strBaseFile,' not found in search path.'));
else hBaseFile = fopen(filepath,'r+t');
end;
end;
%
% The rules contained in RuleBase are in a continuous string, e.g. 'ISMSSTOOOISRMVRPHR...'
% Each rule therefore takes 9 characters. Use this to make up a two dimensional string
% matrix, where each line contains one rule, e.g. 'ISM SST OOO'.
%
Rules(:,1) = RuleBase(1:9:length(RuleBase))'; % 1. character of ISL, ISM or ISR.
Rules(:,2) = RuleBase(2:9:length(RuleBase))'; % 2. character of ISL, ISM or ISR.
Rules(:,3) = RuleBase(3:9:length(RuleBase))'; % 3. character of ISL, ISM or ISR.
Rules(:,4) = setstr(32)*ones(9,1); % Separate with a column of spaces
Rules(:,5) = RuleBase(4:9:length(RuleBase))'; % 1. character of MVL, SST or MVR.
Rules(:,6) = RuleBase(5:9:length(RuleBase))'; % 2. character of MVL, SST or MVR.
Rules(:,7) = RuleBase(6:9:length(RuleBase))'; % 3. character of MVL, SST or MVR.
Rules(:,8) = setstr(32)*ones(9,1); % Separate with a column of spaces
Rules(:,9) = RuleBase(7:9:length(RuleBase))'; % 1. character of PHL, PSL, OOO, PSR or PHR.
Rules(:,10) = RuleBase(8:9:length(RuleBase))'; % 2. character of PHL, PSL, OOO, PSR or PHR.
Rules(:,11) = RuleBase(9:9:length(RuleBase))'; % 3. character of PHL, PSL, OOO, PSR or PHR.
%
% Build the Rule base line by line by printing the rules one by one, e.g. 'ISM SST OOO '.
%
for i=1:9,
fprintf(hBaseFile,'%s %s %s',Rules(i,:));
end;
fclose(hBaseFile);
clear Rules;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -