/matlab_tools/Converted/ksampleworkspace.m

http://github.com/aludnam/MATLAB · Objective C · 203 lines · 200 code · 3 blank · 0 comment · 55 complexity · 566e360e4f143107ab347e19a2efb254 MD5 · raw file

  1. %ksampleworkspace 'Object Packaging of Workspaces in the Sampledata Toolbox '
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros sampleworkspace.pane file
  3. %
  4. % Parameters:
  5. % MultiChoice: wksp 'Select a Sample Workspace to Run', default: 3: 'color arithmetic example'
  6. % InputFile: dummy 'Color Arithmetic', optional: 'if else example'
  7. % InputFile: dummy 'If Else Example', optional: 'simple arithmetic'
  8. % InputFile: dummy 'Simple Arithmetic', optional: 'switch example'
  9. % InputFile: dummy 'Switch Example', optional: 'signal'
  10. % InputFile: dummy 'Signal', optional: 'merge example 1'
  11. % InputFile: dummy 'Merge Example 1', optional: 'complex arithmetic'
  12. % InputFile: dummy 'Complex Arithmetic', optional: 'merge example 2'
  13. % InputFile: dummy 'Merge Example 2', optional: 'geometry'
  14. % InputFile: dummy 'Geometry', optional: 'trigger example'
  15. % InputFile: dummy 'Trigger Example', optional: '5D head'
  16. % InputFile: dummy '5D Head', optional: 'expression example 1'
  17. % InputFile: dummy 'Expression 1', optional: 'wavelets'
  18. % InputFile: dummy 'Wavelets', optional: 'expression example 2'
  19. % InputFile: dummy 'Expression 2', optional: 'formats example'
  20. % InputFile: dummy 'Formats', optional: 'while example'
  21. % InputFile: dummy 'While Example', optional: 'fourier'
  22. % InputFile: dummy 'Fourier', optional: 'count example'
  23. % InputFile: dummy 'Count Example', optional: 'median filter'
  24. % InputFile: dummy 'Median Filter', optional: 'edge filter'
  25. % InputFile: dummy 'Edge Filter', optional: 'render 3d fft'
  26. % InputFile: dummy 'Render 3d FFT', optional: 'procedure example 1'
  27. % InputFile: dummy 'Procedure 1', optional: 'geometry elevation'
  28. % InputFile: dummy 'Geometry Elevation', optional: 'procedure example 2'
  29. % InputFile: dummy 'Procedure2', optional: 'sample workspace to be run'
  30. % Choices are:
  31. %
  32. % Example: ksampleworkspace({dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy, dummy}, {'wksp',3;'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy','';'dummy',''})
  33. %
  34. % Khoros helpfile follows below:
  35. %
  36. % PROGRAM
  37. % sampleworkspace - Object Packaging of Workspaces in the Sampledata Toolbox
  38. %
  39. % DESCRIPTION
  40. %
  41. %
  42. %
  43. % EXAMPLES
  44. %
  45. % "SEE ALSO"
  46. %
  47. % RESTRICTIONS
  48. %
  49. % REFERENCES
  50. %
  51. % COPYRIGHT
  52. % Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.
  53. %
  54. function varargout = ksampleworkspace(varargin)
  55. if nargin ==0
  56. Inputs={};arglist={'',''};
  57. elseif nargin ==1
  58. Inputs=varargin{1};arglist={'',''};
  59. elseif nargin ==2
  60. Inputs=varargin{1}; arglist=varargin{2};
  61. else error('Usage: [out1,..] = ksampleworkspace(Inputs,arglist).');
  62. end
  63. if size(arglist,2)~=2
  64. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  65. end
  66. narglist={'wksp', 3;'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input';'dummy', '__input'};
  67. maxval={0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
  68. minval={0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
  69. istoggle=[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];
  70. was_set=istoggle * 0;
  71. paramtype={'MultiChoice','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile','InputFile'};
  72. % identify the input arrays and assign them to the arguments as stated by the user
  73. if ~iscell(Inputs)
  74. Inputs = {Inputs};
  75. end
  76. NumReqOutputs=0; nextinput=1; nextoutput=1;
  77. for ii=1:size(arglist,1)
  78. wasmatched=0;
  79. for jj=1:size(narglist,1)
  80. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  81. wasmatched = 1;
  82. was_set(jj) = 1;
  83. if strcmp(narglist{jj,2}, '__input')
  84. if (nextinput > length(Inputs))
  85. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  86. end
  87. narglist{jj,2} = 'OK_in';
  88. nextinput = nextinput + 1;
  89. elseif strcmp(narglist{jj,2}, '__output')
  90. if (nextoutput > nargout)
  91. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  92. end
  93. if (isempty(arglist{ii,2}))
  94. narglist{jj,2} = 'OK_out';
  95. else
  96. narglist{jj,2} = arglist{ii,2};
  97. end
  98. nextoutput = nextoutput + 1;
  99. if (minval{jj} == 0)
  100. NumReqOutputs = NumReqOutputs - 1;
  101. end
  102. elseif isstr(arglist{ii,2})
  103. narglist{jj,2} = arglist{ii,2};
  104. else
  105. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  106. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  107. end
  108. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  109. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  110. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  111. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  112. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  113. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  114. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  115. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  116. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  117. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  118. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  119. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  120. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  121. end
  122. end
  123. end
  124. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  125. narglist{jj,2} = arglist{ii,2};
  126. end
  127. end
  128. end
  129. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  130. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  131. end
  132. end
  133. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  134. for jj=1:size(narglist,1)
  135. if strcmp(paramtype{jj}, 'Toggle')
  136. if (narglist{jj,2} ==0)
  137. narglist{jj,1} = '';
  138. end;
  139. narglist{jj,2} = '';
  140. end;
  141. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  142. narglist{jj,1} = '';
  143. narglist{jj,2} = '';
  144. end;
  145. if strcmp(narglist{jj,2}, '__input')
  146. if (minval{jj} == 0) % meaning this input is required
  147. if (nextinput > size(Inputs))
  148. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  149. else
  150. narglist{jj,2} = 'OK_in';
  151. nextinput = nextinput + 1;
  152. end
  153. else % this is an optional input
  154. if (nextinput <= length(Inputs))
  155. narglist{jj,2} = 'OK_in';
  156. nextinput = nextinput + 1;
  157. else
  158. narglist{jj,1} = '';
  159. narglist{jj,2} = '';
  160. end;
  161. end;
  162. else
  163. if strcmp(narglist{jj,2}, '__output')
  164. if (minval{jj} == 0) % this is a required output
  165. if (nextoutput > nargout & nargout > 1)
  166. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  167. else
  168. narglist{jj,2} = 'OK_out';
  169. nextoutput = nextoutput + 1;
  170. NumReqOutputs = NumReqOutputs-1;
  171. end
  172. else % this is an optional output
  173. if (nargout - nextoutput >= NumReqOutputs)
  174. narglist{jj,2} = 'OK_out';
  175. nextoutput = nextoutput + 1;
  176. else
  177. narglist{jj,1} = '';
  178. narglist{jj,2} = '';
  179. end;
  180. end
  181. end
  182. end
  183. end
  184. if nargout
  185. varargout = cell(1,nargout);
  186. else
  187. varargout = cell(0);
  188. end
  189. global KhorosRoot
  190. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  191. w=['"' KhorosRoot];
  192. else
  193. if ispc
  194. w='"C:\Program Files\dip\khorosBin\';
  195. else
  196. [s,w] = system('which cantata');
  197. w=['"' w(1:end-8)];
  198. end
  199. end
  200. callKhoros([w 'runwksp" '],Inputs,narglist);