|
Mark S Dehaan <MSD@INEL.GOV> writes
>> I've written it in SCL, but it could easily be converted to a SAS data step.
>
>Mark,
>
>I have converted to Data Step language. I still can't read Morse code, but it is
>fun!
>
Ready for some fun, I tried out this data step solution, but
perhaps my platform is different, anyway, it failed.
Fixing this is almost as much fun....
You can copy this from email to the clipboard,
then in a SAS session, on WinXX,
submit clipboard menu option
or gsubmit buffer=default command
The text and morse code are displayed just before the tones are heard
(when it works NB sound() and sleep() are platform dependant )
*text to send;
%let text =
Mark Bodt, SAS Programmer Extraordinaire - Iceberg Ahead ;
*create morse code format;
proc format;
value $morse
'A'='.-' 'B'='-...' 'C'='-.-.' 'D'='-..'
'E'='.' 'F'='..-.' 'G'='--.' 'H'='....'
'I'='..' 'J'='.---' 'K'='-.-' 'L'='.-..'
'M'='--' 'N'='-.' 'O'='---' 'P'='.--.'
'Q'='--.-' 'R'='.-.' 'S'='...' 'T'='-'
'U'='..-' 'V'='...-' 'W'='.--' 'X'='-..-'
'Y'='-.--' 'Z'='--..' '1'='.----' '2'='..---'
'3'='...--' '4'='....-' '5'='.....' '6'='-....'
'7'='--...' '8'='---..' '9'='----.' '0'='-----'
'.'='.-.-.-' ','='--..--' ':'='---...' '?'='..--..'
"'"='.----.' '-'='-....-' '/'='-..-.' '(' ='-.--.-'
')'='-.--.-' '"'='.-..-.' other=' ';
run;
* prepare line by line feed back on log;
dm 'log; autopop on; autoscroll 1' pgm;
data _null_;
*silly morse code program from ideas by Mark Bodt April 1999 ;
*specify parameters;
label dur_spac = 'space duration (msec)'
dur_dot = ' dot duration (msec)'
dur_dash = ' dash duration (msec)'
;
retain
dur_spac 1000
dur_dot 200
dur_dash 400
tone 2000/*hertz*/ ;
retain
morse '............'
char m_char '.'
/* text to convert */
text "&text"
;
*for each character in the string;
do x=1 to length(text);
*get an individual character;
char=upcase(substr(text,x));
*convert the letter to morse code;
morse=put(char,$morse.);
* display the plain and morsed character;
put char morse ;
*leave a pause between each morsed character;
s = sleep( dur_spac/1000 ) ;
if x >15 and dur_spac > 500 then
do;
** speed up after first 15 characters ;
dur_spac =300 ;
dur_dot =100 ;
dur_dash =200 ;
end;
*for each dot dash in the
morse character sound a tone;
do y=1 to length(morse);
m_char=substr(morse,y,1);
select ( m_char );
when ( '.' ) call sound(tone,dur_dot);
when ( '-' ) call sound(tone,dur_dash);
when ( ' ' ) s = sleep( dur_spac/1000 );
otherwise put m_char @;
end;
end;
end;
run;
* switch off line by line feed back on log;
dm 'log; autopop off; autoscroll 0' pgm;
>
>+------------------------------------------+--------------------------+
>| Mark Bodt | |
>| Sunken Treasure Software Systems Ltd | SAS Institute(NZ) Ltd. |
>| Specialising in SAS(R) Software | Quality Partner. |
>| Consultancy in the Asia / Pacific Region | |
>+------------------------------------------+--------------------------+
>| PO Box 9472, Marion Square, Wellington, New Zealand |
>| Ph (025) 725 386 Fax +64 4 385 8670 Email: markbodt@stss.co.nz |
>+---------------------------------------------------------------------+
<<<.............well it was his idea.....
--
Peter Crawford
|