User:Ian Clark/KISS/Getting started with DateNow

From J Wiki
Jump to: navigation, search

This "Getting-Started" guide refers to a JHS client which you can download as an OS X app here:

See here: for a brief introduction to KISS.

First Steps

++ Launch the app (with JHS NOT RUNNING)

-- [Client Date] and [Server Date] should show the same date+time (referred-to as a "date").

([Server Date] may occasionally show 1 second later.)

++ Click button: Dates

-- updates both [Client Date] and [Server Date].


  • DateNow (the "client") reads the system clock and outputs it to [Client Date].
  • Then DateNow sends a message the JHS server (by sending it a URL) and asks it to read the system clock itself and send back the result as a formatted date string. The message takes the form of a URL (viz: http://localhost:65001/datenow?now).

-- JHS sends back a string to, which outputs it without alteration to [Server Date].

The time taken for JHS to receive the message, act on it and send back the answer as a string causes a barely perceptible delay between the two dates.

This is a very simple app, in which JHS generates the current date as a service to The app is well able to do this all by itself, and does so, to serve for comparison. However JHS might instead perform a much more elaborate task, sending the data back as a XML string, which is capable of updating many fields at once, or even drawing a picture. XML is recommended by Apple as a means of encoding just about any sort of data imaginable.

++ Click button: [J Version]

-- The TV panel (short for "TextView", Apple's name for this sort of screen object) fills with the familar format of JVERSION.

(This is how JHS tells you details about itself and the machine it is running on.)

++ Click button: [Go]

-- The button title changes to [Stop] and the two dates are repeatedly refreshed.

This is a repeated process called the "idle task".

The idle task runs every half-second (you can change this). Each time it runs, it toggles the state of the [Idle Wink] checkbox, used here simply as an indicator light.

++ Click button: [Stop] (…which was [Go])

-- The button title changes back to [Go] and the two dates stop being refreshed.

Most applications don't need an idle task to be running all the time. But without it, would just sit there doing nothing until you clicked a button. The idle task enables DateNow to do something useful, viz to keep a constant watch on the JHS server, making sure it is still alive and working correctly.

A simpler client for JHS would not bother to do this. It would assume JHS had been fired-up at system startup and could be relied upon to provide services until system shutdown. However one JHS server serves multiple apps, some of which may undergo development whilst DateNow is in use. Some control over the server is a good thing to have.

Let us see how much DateNow can control the server...

++ Click button: [Go] (…to start the idle task again).

-- [Idle Wink] resumes winking and the dates are periodically refreshed.

++ Click button: [svr state]

-- The TV panel shows a continually updated display like this:

serverIsAlive = true
serverKnowsAppname = true
serverIsInitialized = true
relaunchDisabled = false
relaunchHasBeenTried = 4
idleCountdown = 0

The first three parameters refer to the server state. But they reside in the client itself, not the server. If the server vanishes, the flags persist and carry on showing the last values they were updated with. But every time the idle task fires, it polls the server and updates these parameters.

++ Click button: [kill svr]

-- The [server Date] field stops being updated and becomes blank.
The [JHS is Savvy] checkbox becomes empty.
The first 3 lines of the TV display change to this:

serverIsAlive = false
serverKnowsAppname = false
serverIsInitialized = false

++ Click button: [init svr]

-- The [server Date] field starts showing the current date again.
The [JHS is Savvy] checkbox becomes checked.
The first 3 lines of the TV display change back to this:

serverIsAlive = true
serverKnowsAppname = true
serverIsInitialized = true

Try the [kill svr] and [init svr] buttons over and over again and watch what happens…

The app is able to relaunch JHS if it terminates.

++ Click button: [Stop]

Don't leave the idle task running for long, because "printlog" builds up indefinitely.

Other things to try

a. Open a browser (e.g. Safari) and try the effect on DateNow of launching and terminating JHS directly.

b. While the idle task is running in DateNow, disable the "datenow" app in JHS by typing into the browser jijx page:


Click the [kill svr] and [init svr] buttons to relaunch a working JHS.

c. While the idle task is running in DateNow, "uninstall" JHS itself by renaming the folder:




(…This simulates J805 not being installed.)

After one idle task cycle, the app will display the message:

  ...JHS server is not installed on this computer

Now restore the folder name:


After one idle task cycle, the app will recover and resume using the server.

d. Choose Menu Help > Edit labels
Make a small change to the wording (e.g. to the window title).
Cick [setup] to restart the app with the altered data.

e. Choose Menu Help > Edit paths
Do as you did in d. but change e.g. IDLETIME to a shorter time interval, e.g. 0.2 (seconds).

f. Choose Menu Help > Edit starter.ijs
If you are brave enough, try altering the J code with which DateNow (re)starts JHS.
e.g. change the statement:

  AUTO=: 0


  AUTO=: 1

(Keep a copy so you can restore it.)
For your changes to take effect, click [kill svr] then [setup].

The app will now launch the browser on startup to show the JHS session log (jijx).