Startsidan  ▸  Texter  ▸  Teknikblogg

Anders Hesselbom

Programmerare, skeptiker, sekulärhumanist, antirasist.
Författare till bok om C64 och senbliven lantis.
Röstar pirat.

Bars in The Wall


Edit: This post concerns “The Wall”, a discontinued project.

Please read this first. This post shows how to display bars using The Wall.

Bars are created using the RegisterBarItem function. These are the arguments:

Parameter 1: UpdateFrequency (32 bit integer) tells how often the text should be updated (that is, how often the callback function will be called) in seconds. 0 means that the item never will be updated. All callback functions are called at startup, and if the UpdateFrequency parameter is greater than 0, it will be called again and again until The Wall is closed. In the example above, CallbackA will be called once, CallbackB will be called each second and CallbackC will be called every two seconds.

Parameter 2: Name (string) is the name of the item for later reference.

Parameter 3 and 4: The X and Y position in characters for the item.

Parameter 5: The color of the item in HTML format.

Parameter 6: The name of the callback procedure. All callback procedures take one object parameter. The type of the object that is passed depend on the type of item you add.

In the following example, I create four bars, and I then use the GetItem function to get a reference to each bar so that I can set some properties of the bar.

HighAlarmLevel gets or sets how high value the Value property can be before it causes the bar to enter alarm state.

LowAlarmLevel gets or sets how low the value of the Value property can be before it causes the bar to enter alarm state.

Orientation gets or sets the bar orientation. It can be Horizontal or Vertical.

Size gets or sets the height of a vertical bar or the length of a horizontal bar.

ValueVisible gets or sets whether the value of the bar will be printed out on the bar. If so, ValueColor control the color and DecimalCount controls the number of decimals that will be used.

Finally, the script holds the callback functions for the four bars. I have chosen to call them UpdateFirstBar, UpdateSecondBar, UpdateThirdBar and UpdateFourthBar.

'Grey background color.
BackgroundColor = "#666666"

'Register 4 bars, each with one second interval.
RegisterBarItem 1, "Bar1", 3, 1, "#00ff00", "UpdateFirstBar"
RegisterBarItem 1, "Bar2", 7, 1, "#00ff00", "UpdateSecondBar"
RegisterBarItem 1, "Bar3", 1, 5, "#00ff00", "UpdateThirdBar"
RegisterBarItem 1, "Bar4", 1, 6, "#00ff00", "UpdateFourthBar"

Dim B

'Do some initialization of the first bar:
Set B = GetItem("Bar1")
B.HighAlarmLevel = 10
B.DecimalCount = 2
B.Orientation = Vertical
B.ValueColor = "#ffffff"
B.Size = 4

'Do some initialization of the second bar:
Set B = GetItem("Bar2")
B.Orientation = Vertical
B.ValueVisible = False
B.Size = 4

'Do some initialization of the third bar:
Set B = GetItem("Bar3")
B.Orientation = Horizontal
B.ValueVisible = False
B.Size = 9

'And the fourth:
Set B = GetItem("Bar4")
B.HighAlarmLevel = 10
B.DecimalCount = 2
B.Orientation = Horizontal
B.ValueColor = "#ffffff"
B.Size = 9

'The callbacks. Item.Value is a double that represents the fill percentage.

Sub UpdateFirstBar(ByVal Item)
   Item.Value = (Item.Value + 0.31)
End Sub

Sub UpdateSecondBar(ByVal Item)
   Item.Value = (Item.Value + 0.5)
End Sub

Sub UpdateThirdBar(ByVal Item)
   Item.Value = (Item.Value + 2)
End Sub

Sub UpdateFourthBar(ByVal Item)
   Item.Value = (Item.Value + 1)
End Sub

This is a screenshot of The Wall running the above script:

Categories: Programs

Tags: The Wall

Leave a Reply

Your email address will not be published. Required fields are marked *

En kopp kaffe!

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!

Bjud på en kopp kaffe!


Kontaktuppgifter, med mera, finns här.

Följ mig

Twitter Instagram
GitHub RSS

Public Service

Folkbildning om public service.

Hem   |   |   |   |   Filmtips