![]() |
Rick's b.log - 2023/08/14 |
It is the 10th of April 2025 You are 3.135.192.183, pleased to meet you! |
|
mailto:
blog -at- heyrick -dot- eu
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:
TRUE
if the user clicked the Primary (OK) button or pressed Enter; or FALSE
if the Cancel button or pressed Escape.
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 dialogue_show(DIA_NORMAL); // Handle the dialogue UI if ( dialogue_do() ) { // TRUE response, user clicked OK button OS_CLI("ScreenSave $.dialogue"); // 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 dialogue_dismiss();
This would make the following dialogue.
You can see most of the different sorts of objects there.
Delete
or 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).
Enter
will also provide a TRUE response as if the user clicked the primary button.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_init("Critical error!"); dialogue_addtext("Unfortunately reality is broken and your chosen"); dialogue_addtext("options cannot be applied."); dialogue_addtext("Please die, and then try again."); dialogue_addbuttons("Terminate", ""); dialogue_show(DIA_ERROR); dialogue_do(); 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.
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.
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.
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!
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!
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.
No comments yet...
© 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. |