mailto: blog -at- heyrick -dot- eu
I'm having a "pont" today. This means that since the previous two days were a weekend, and tomorrow is a public holiday, we're not working this single day in the middle.
That's good, because, honestly, I felt like crap this morning. Got up at half six, fed furry and had tea, then went back to bed.
Next thing I know, it's just going ten.
I don't like Mondays.
Anyway, I'm working on something. I'm not going to say what at the moment, but it runs in a single-tasking mode (no, it's not a game), and in order to be able to accept input from the user in a nicer method than OS_ReadLine (that's basically INPUT), I decided to create a "dialogue manager".
Based upon the way OPL used to work on the Psion organiser, there are six primary stages of creating a dialogue:
- Initialise the dialogue.
This is a simple call to dialogue_init() passing a dialogue title. This sets up the memory for an empty dialogue.
- Add things to the dialogue.
There are various types of object that can be added. Text messages, check boxes, radio options, string input, selection choices, buttons...
If you will need to read information from the dialogue in the future, you will need to remember the object handle.
- Show the dialogue on the screen.
This will iterate through the added objects and will work out how big the dialogue needs to be to fit everything into it, and to place it centred on the screen.
At this point, dialogue content cannot be changed except as provided by the user interface. You can't add/remove objects.
- Let the dialogue manager handle the user interface.
This is a simple call to dialogue_do() that will handle the entire UI behaviour, and will return
TRUE if the user clicked the Primary (OK) button or pressed Enter; or
FALSE if the Cancel button or pressed Escape.
- Read information from the dialogue, as necessary.
- Finally, dismiss the dialogue (with dialogue_dismiss(). This will free the memory used, and restore things.
It is acceptable to call dialogue_do() multiple times, so you can check values on exit from the UI and pop up a message if something is wrong, then go back to dialogue_do() so the user can do something about it.
Multiple dialogues are possible. Only the most recently used is the current. This is a dialogue manager, not a window manager. ☺ But it does mean you can use a dialogue on top of a dialogue to notify the user of problems.
In this case, dialogue_dismiss() will, if there's a previous dialogue, restore the previous dialogue context.
Here is some example code.
// At the top
dialogue_handle diaref = NULL;
object_handle behaviour = NULL;
object_handle runaround = NULL;
object_handle throwstuff = NULL;
object_handle newname = NULL;
int optval = 0;
// Create the dialogue
diaref = dialogue_init("How to handle the world");
dialogue_addtext("The world is screwed. How do you intend to cope with it?");
behaviour = dialogue_addradio("Behaviour", "Scream", "Panic quietly", "Meh",
"Laugh", "Get drunk", "", "", "", 2);
runaround = dialogue_addcheck("Options", "Run around with arms in the air", TRUE);
throwstuff = dialogue_addcheck("", "Throw random items of furniture", FALSE);
dialogue_addtext("If you wish to be known by another name, enter it below.");
newname = dialogue_addstring("Name", "Tiamat", STRING_MAX);
dialogue_addbuttons("Accept reality", "Deny everything");
// Show it on-screen
// Handle the dialogue UI
if ( dialogue_do() )
// TRUE response, user clicked OK button
// You would read options like this
optval = dialogue_readcheck(runaround);
// is TRUE if option checked, else FALSE
// else FALSE if user clicked Cancel button
// We're done, so dismiss this dialogue
This would make the following dialogue.
An example dialogue.
You can see most of the different sorts of objects there.
- Text object
Spans the entire width of the dialogue and just contains some text.
- Checkbox object
A little checkbox that you can use to turn options on and off. Comprised of an optional caption (on the left) and object description text, along with a default value (if it's to be checked or not).
- Radio object
A set of options (up to eight) with rounded selection buttons (to make them appear different to the checkbox). It's called "radio" because like the buttons on an old-fashioned radio, only one can be selected. Clicking one will deselect the others. As before, an optional caption, option descriptions, and which one is selected by default.
- String object
This is a simple string entry editor. When the white part is clicked in, the UI switches to character entry mode, and characters entered on the keyboard will be inserted into the string shown. A red caret (not shown) will dictate the current edit location.
Backspace remove the character to the left of the caret, and since this is RISC OS
^U will erase the entire string. You can specify custom lengths up to the maximum (31 characters).
- Choice object (not shown)
If you provide an array of strings, this creates an icon with up/down arrows and you can click to choose a different option, which will change what is shown in the object. Consider, for example, a list of countries or favourite pizza toppings. Holding Ctrl while clicking will go forward/backward ten entries in order to make things faster.
- Button object
You can specify one or two buttons. The first is the obligatory primary button (shown on the right) which is the action that results in a TRUE response from the dialogue. Pressing
Enter will also provide a TRUE response as if the user clicked the primary button.
The second is an optional cancel button (shown on the left), which is the button that results in a FALSE response from the dialogue. Pressing
Escape will do the same thing, but note that pressing
Escape will always return a FALSE response regardless of whether or not a cancel button is visible.
If we edit the code around dialogue_do() as follows...
// Handle the dialogue UI
if ( dialogue_do() )
// TRUE response, user clicked OK button
// One can overlay a dialogue on another
// We aren't remembering any handles as we only want to show this,
// so the handles aren't required.
dialogue_addtext("Unfortunately reality is broken and your chosen");
dialogue_addtext("options cannot be applied.");
dialogue_addtext("Please die, and then try again.");
dialogue_dismiss(); // will restore the previous dialogue context
It will demonstrate overlaid dialogues as shown just below. Also worth noting is that since we aren't interested in reading anything back from this dialogue, there's no need to bother with any of the handles. Just create it, show it, wait for the user to do something, then discard it.
No, that isn't right, something went wrong!
193 lines of header file, and 1857 lines of code. Not bad for a weekend. Well, I say weekend. I wrote most of the code yesterday.
It's simple, but it does what I wanted and it looks better than simply asking the user to enter input.
Amazon dispatched my battery yesterday evening. Colis Privé got it to me in the morning before, even, the post person had been around.
The replacement battery.
I cut off the Molex plug and soldered the terminals to the associated pads within the headphones. As I didn't have sticky to hold the battery in place, I Blue Petered something using a piece of plastic cut from the bottom of a cheese pack.
The headphones, fixed.
As you can see, from the green indicator (rather than blue), the active noise cancelling is working again. As the old battery was on the way out, that only worked sometimes.
The ear pads are a bit naff, but they're the headphones I wear at work and while out shopping, so it's nice to get them operating again - and with the noise cancelling too. Nice!
Speaking of cheddar packs, I bought myself another pack of the Super U's own brand sliced cheddar. In the shop I turned the pack over, read the back, and would have burst into laughter if I had anything that resembled a functional emotional response. I did, sort of, manage a smirk.
Oh, look, Stranraer.
So, asides from some outliers like Cathedral City, it seems as if most of the cheddar in France (from my sample of two supermarkets!) comes from this one factory in Scotland.
Now, this isn't as crazy as it might seem, as the factory is owned and run by Lactalis, which being a multinational will have some experience in all of the Brexit-inflicted bullshit that have caused problems with imports into Europe.
To put this into context, British tourists are not allowed to take any meat or dairy products with them. Which means, yes, cheese and pickle sandwiches and bacon butties may be confiscated by customs.
It's pathetic, but since the UK is no longer part of the EU customs area... it's "what the people voted for", apparently. I think, having been a part of the EEC then the EU for as long as I've been alive, people didn't really appreciate exactly how much freedom the customs arrangements actually gave everybody. I mean, my brain nearly exploded when the Brexiteers tried to say that leaving the EU would be less red tape (how's that one working out?).
So, having a big French company running this Scottish cheese factory is perhaps the best way to get imports into the EU sorted. Granted, it might reduce choice (my Cathedral City that is sometimes available from the Leclerc in Big Town is aged nine months...), but on the other hand a reduced choice is better than erratic or no choice.
Besides, I've been eating the Seriously Strong since before I even came to France!
As part of my tidying up outside, I have cut away all of the dead bits of the buddleia. Remember, this was a mess of brambles as tall as me.
What's left of the buddleia.
Look mummy! I've changed my gender! 😂
But, yeah... got fed up with my hair so an old pair of scissors and five minutes of inept snipping at random bits and... it probably looks crap but I might manage a shrug if I try really hard.
I'm more upset about the lack of colour.
Today was the day that I had predicted to take my little car for it's service. Well, since I haven't gone to Big Town, or vide greniers, or anywhere actually... I still have 914km before the counter hits zero.
That's about six and a half weeks at current use.
Please note that while I check this page every so often, I am not able to control what users write; therefore I disclaim all liability for unpleasant and/or infringing and/or defamatory material. Undesired content will be removed as soon as it is noticed. By leaving a comment, you agree not to post material that is illegal or in bad taste, and you should be aware that the time and your IP address are both recorded, should it be necessary to find out who you are. Oh, and don't bother trying to inline HTML. I'm not that stupid! ☺ ADDING COMMENTS DOES NOT WORK IF READING TRANSLATED VERSIONS.
You can now follow comment additions with the comment RSS feed. This is distinct from the b.log RSS feed, so you can subscribe to one or both as you wish.
(Felicity? Marte? Find out!)
- SimpleSeq v0.09, UV lamp fail, Stupid retro prices, A little bit of gardening, European content on streaming services. (2023/09/23)
- Big Town, Citizen CX-32N printing calculator, Socotel S63 - yes another. (2023/09/22)
- SimpleSeq v0.08, UV bug lamp failure, Not going to Nantes, Cooler mods, And... (2023/09/21)
- Expression evaluation with ChatGPT. (2023/09/20)
- Happiness from the tax man, Blind idiot code translation. (2023/09/19)
List all b.log entries
Return to the site index
PS: Don't try to be clever.
It's a simple substring match.
Last read at 00:56 on 2023/09/26.
© 2023 Rick Murray
This web page is licenced for your personal, private, non-commercial use only. No automated processing by advertising systems is permitted.
RIPA notice: No consent is given for interception of page transmission.