Using Guide, export a code to a .txt file HELP HEL HELP

Hey guys, I want to export this code to a txt file when I pressed a push button in guide:
cblock
cuenta1
cuenta2
cuenta3
endc
p equ d'66'
m equ d'100'
n equ d'100'
retardo
movlw p
movwf cuenta1
dec1
movlw m
movwf cuenta2
dec2
movlw n
movwf cuenta3
dec3
decfsz cuenta3
goto dec3
decfsz cuenta2
goto dec2
decfsz cuenta1
goto dec1
return
thank you very much,

Answers (1)

S = { 'cblock '
'cuenta1'
'cuenta2'
'cuenta3'
'endc'
''
'p equ d''66'' '
'm equ d''100'' '
'n equ d''100'' '
'retardo'
'movlw p'
'movwf cuenta1 '
'dec1'
'movlw m'
'movwf cuenta2 '
'dec2'
'movlw n'
'movwf cuenta3 '
'dec3'
'decfsz cuenta3 '
'goto dec3 '
'decfsz cuenta2'
'goto dec2'
'decfsz cuenta1'
'goto dec1'
'return' };
fid = fopen('NameOfOutputFile', 'wt');
fprintf(fid, '%s\n', S{:});
fclose(fid);
Are you certain that you want the trailing blanks on lines? You do not appear to have used trailing blanks in a consistent manner.

2 Comments

The spaces it is not problem, and thank you very much it really works, and did you know how to modify a code and then print in a txt file: example
Hello World
My name is: 'Name'
And I want to modify 'Name' with the name they put in the Guide and then print.
fid = fopen('NameOfOutputFile', 'wt');
fprintf(fid, 'Hello World\nMy name is: ''%s''\n', NameUserGave);

Sign in to comment.

Categories

Tags

No tags entered yet.

Asked:

on 11 Apr 2017

Commented:

on 11 Apr 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!