Jump to content

Recommended Posts

Posted

Hi folks,

 

Yesterday evening I found myself with no internet and no means of setting an alarm (I use an online alarm clock since the computer is never off). Not one to be discouraged to go out without a fight I wrote the following, in no way practical, alarm function that I thought would be fun to share with the community.

 

NOTE: This function is nothing more than the product of a lot of guess work

 

(vl-load-com)
;param d: time offset from the time the function is called.
(defun alarm (d / cdate getUpAt cdate track wmplayer loop)
   (setq track "c:\\alarm.mp3")
   (setq cdate (getvar 'date))
   (setq getUpAt (+ cdate d))
   (setq loop t)
   (while (= loop t)
       (setq cdate (getvar 'date))
       (if(<= getUpAt cdate)
           (progn
               (setq wmplayer (vlax-create-object "WMPlayer.OCX.7"))
               (vlax-put wmplayer 'url track)
               (setq loop nil)
           )
       )
   )
)

Posted

Where's the function to trigger this alarm? I assume you use a reactor otherwise you will need to call this routine from time to time.

 

You can also incorporate a "local" callback function within a lisp program to check 'CDATE before runing the main routine. if conditon is True then pass the argument to your routine. any method you choose, It is vital to use a "trigger" for this to be an effective alarm clock. or maybe i'm just missing something

 

;)

Posted
Where's the function to trigger this alarm? I assume you use a reactor otherwise you will need to call this routine from time to time.

 

You can also incorporate a "local" callback function within a lisp program to check 'CDATE before runing the main routine. if conditon is True then pass the argument to your routine. any method you choose, It is vital to use a "trigger" for this to be an effective alarm clock. or maybe i'm just missing something

 

;)

 

Nope you're one hundred percent correct; the function itself isn't practical for recurring use, it was created solely as an end to a means. I've only posted it for its humourous nature, possibly to show that if a computer can carry out a task it can be written in lisp lol.

 

I had thought about using a reactor to trigger it but it was past my bed time so I just let it loop over night :oops:

Posted

I had thought about using a reactor to trigger it but it was past my bed time so I just let it loop over night :oops:

 

Thats what i thought :)

 

Anyhoo. Good stuff SOliver

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...