LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (April 1999, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 14 Apr 1999 21:27:32 +0100
Reply-To:     Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Peter Crawford <Peter@CRAWFORDSOFTWARE.DEMON.CO.UK>
Subject:      Re: SAS Silliness: text to morse code using sound() function
In-Reply-To:  <87256753.006395EC.00@lnsmtp01.inel.gov>

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


Back to: Top of message | Previous page | Main SAS-L page