Elmo HARmonica, HARSFEN0602 software manual 216, Converter Call, Algorithm, Conversion Process

Models: HARmonica HARSFEN0602

1 220
Download 220 pages 51.63 Kb
Page 218
Image 218

HARSFEN0602ElmoHARmonicaSoftwareManual

PRELIMINARYDRAFT

18Appendix C: Converting Clarinet/Saxophone programs to the Harmonica language

216

18.1The Converter

The user program syntax for the Saxophone or Clarinet is different from the Harmonica’s syntax. The converter program provides an easy method to convert Saxophone/Clarinet style programs to the Harmonica syntax.

The converter program requires that the source Sax/Cla program is a simple text file.

If the Sax/Cla has been produced by the Composer program in .pgm (actually reach edit) format, be sure to convert it first to text.

18.2The Converter Call

The converter is a console application. It gets their arguments from the command line. The arguments are the following:

1.The first argument is the name of the input file with a user program. The default is the file named “OldFormat.txt” from the current directory. If such file does not exist, the program exits doing nothing.

2.The second argument is the name of the output file that contains new text of the user program. The default is the file named “NewFormat.txt” in the current directory.

This file will be created (if it does not exist) or updated (if it exists) only if the conversion is successful.

3.The third argument is the name of the output file that contains errors of compilation. The default is the file named “Errs.txt” in the current directory.

This file will be created (if it does not exist) or updated (if it exists) only if the conversion or compilation is failed.

4.The fourth argument is SaveOldTextflag. A user may desire to save an old program text inside comment block for comparison with the text after conversion. The default is 0, i.e. an old text is not saved. If this command line argument is ‘1’ – the format before conversion is saved inside C-style comment block (/* … */).

Example:

ConvSyn MySax.prg NewHar.txt 1

Converts the old program MySax.prg to the new program NewHar.txt, preserving the old Sax-style code, commented.

18.3The Algorithm

The converter program does the following:

1.Load program text input file.

2.Try to compile old format text in order to verify that initial text is valid according to the Saxophone/Clarinet syntax. If the compilation failed - it writes error to the error output file and exits.

3.If SaveOldTextflag (the fourth command line argument) is ‘1’, save it inside comment block as it is.

4.Convert to the new format.

5.Writes new program text to the output file.

18.4The Conversion Process

Most the program flows instructions of the Sax/Cla need to be converted for an Harmonica application. The table below presents a list of the changes with the brief explanation.

N

Description

Saxophone/Clarinet

Harmonica

1

AF command

AF,cond

until cond

 

The keyword ‘until’ is used instead the

 

 

Page 218
Image 218
Elmo HARmonica, HARSFEN0602 software manual 216, Converter Call, Algorithm, Conversion Process