MATLAB's File I/O routines can be used to print the contents of a list box to a text file. Once the text file is created use DOS or UNIX commands to send that text file to a printer. For example,
txt_cell = {'This is the first line';'This is the second';'This is the third'};
h = uicontrol('style','list',...
'Position',[20 20 200 80],...
'max',10,'min',1,...
'string',txt_cell);
str = get(h,'String');
fid = fopen('myfile.txt','wt');
fprintf(fid,'%s \n',str{:});
fclose(fid);
type myfile.txt
This is the first line
This is the second
This is the third
!copy /b myfile.txt lpt1:
1 file(s) copied.
Best Answer