RosettaCodeData/Task/Sleep/NetRexx/sleep.netrexx

38 lines
904 B
Plaintext

/* NetRexx */
options replace format comments java crossref symbols nobinary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method sleep(secs) public static binary
ms = (secs * 1000).format(null, 0) -- milliseconds, rounded to nearest integer
say 'Sleeping...'
do
Thread.sleep(ms)
catch ix = InterruptedException
say 'Sleep interrupted!'
ix.printStackTrace()
end
say 'Awake!'
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) public static
secs = -1
loop until \secs.datatype('N')
if secs > 0 then do
say 'Napping for' secs's'
say
sleep(secs)
end
say
say 'How many seconds do you want me to sleep? (enter something non-numeric to terminate)\-'
parse ask secs .
say
end
say
say 'Goodbye...'
say
return