Author Topic: Help Writing an MOTD Script  (Read 1287 times)

0 Members and 1 Guest are viewing this topic.

dubb

  • Swamp Rat
  • Posts: 1105
Help Writing an MOTD Script
« on: September 11, 2015, 07:00:34 PM »
I happen to write several scripts for the office and update our drafters on new updates to blocks, tools, and cad related stuff. I wanted to write a start-up script that would alert whoever has our custom start-up scripts that there has been an update to xyz. The basic idea would be a "Message of the Day" type of alert. I don't want them to always see this alert since we don't do updates all the time. I tried doing this with "setenv" and "getenv". I wrote some sample code that I haven't ran for what I was thinking about doing but. I may need a trigger the variable "motd". but if it resides in the start-up file it gets weird.

Code: [Select]
;motd enabled
(setenv "motd" "1")

(if (= (getenv "motd") 1)
     (alert "Message tip of the day)
     (t < (getenv "motd") 1)
)

Code: [Select]
;motd disabled
(setenv "motd" "0")

(if (= (getenv "motd") 1)
     (alert "Message tip of the day)
     (t < (getenv "motd") 1)
)

Thanks.   :-)

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Help Writing an MOTD Script
« Reply #1 on: September 12, 2015, 06:09:50 AM »
You will probably need some kind of message ID. Perhaps based on the date?
Code: [Select]
(if (/= (getenv "motd") "20150912")
  (progn
    (alert "Message tip of the day 20150912")
    (setenv "motd" "20150912")
  )
)

But this will only show the last message to the user and somebody who is away for a couple of days may miss messages.

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Help Writing an MOTD Script
« Reply #2 on: September 12, 2015, 06:56:47 AM »
Perhaps you could use my Evaluate Once on Startup function - this way, you would not need to write to the registry using setenv.

ChrisCarlson

  • Guest
Re: Help Writing an MOTD Script
« Reply #3 on: September 14, 2015, 08:02:19 AM »
You could use a .CSV file with Date / Message format, read the file, evaluate the date compared to the last set registry date and display all rows > last saved date.