BBCSDL: Using the clipboard

Discussions related to mouse, keyboard, fonts and Graphical User Interface
p_m21987
Posts: 177
Joined: Mon 02 Apr 2018, 21:51

BBCSDL: Using the clipboard

Post by p_m21987 »

Hello,

How would you go about copying data to and from the clipboard in BBCSDL?
I checked the manual and found information relating to BB4W ( http://www.bbcbasic.co.uk/bbcwin/manual ... gclipboard ) but it seems like it doesn't work in BBCSDL - I get a 'no such system call' error.
Last edited by p_m21987 on Wed 26 Dec 2018, 16:54, edited 1 time in total.
guest

Re: BBCSDL: Using the clipboard

Post by guest »

Patrick M wrote: Tue 17 Apr 2018, 14:44 How would you go about copying data to and from the clipboard in BBCSDL?
You have two options in a case such as this: either copy the relevant code from a program that you know already has the functionality you need (the obvious example being SDLIDE.bbc itself, from which you can borrow code from the FNhascliptext, PROCcopytext() and PROCpaste() routines) or code it yourself using information from the SDL 2.0 API documentation (i.e. SDL_HasClipboardText, SDL_SetClipboardText and SDL_GetClipboardText).

When the SDL API functions are straightforward to use, as they are in this case, you probably might as well go straight to the horse's mouth, but if they are a bit more tricky finding the relevant code in one of the supplied examples - assuming there is one - will give you more 'context'. It's not my intention to try to write something equivalent to the 'Accessing the Windows API' segment of the BB4W documentation, but for BBCSDL. It would be a lot of work, and I think (or at least hope) BBC BASIC programmers are now more au fait with calling APIs than they were back in 2001. :geek:

Richard.
p_m21987
Posts: 177
Joined: Mon 02 Apr 2018, 21:51

Re: BBCSDL: Using the clipboard

Post by p_m21987 »

Thanks Richard, this worked perfectly. I've now got some BASIC functions that call the SDL functions.
Last edited by p_m21987 on Wed 26 Dec 2018, 16:54, edited 1 time in total.
p_m21987
Posts: 177
Joined: Mon 02 Apr 2018, 21:51

Re: BBCSDL: Using the clipboard

Post by p_m21987 »

Sorry to ask another question so soon, but I would like to know, what's the best method to test whether your program is running on BB4W or BBCSDL?
Last edited by p_m21987 on Wed 26 Dec 2018, 16:54, edited 1 time in total.
guest

Re: BBCSDL: Using the clipboard

Post by guest »

Patrick M wrote: Tue 17 Apr 2018, 19:13what's the best method to test whether your program is running on BB4W or BBCSDL?
I would usually do:

Code: Select all

      IF INKEY$(-256) = "W" THEN
        REM Running in BB4W
      ELSE
        REM Running in BBCSDL
      ENDIF
If you're going to do it frequently, set a global Boolean variable rather than repeating the INKEY$() every time. If you need to check any other possible BBC BASIC versions (albeit that it's unlikely) there's a list of INKEY(-256) values at Jonathan Harston's site (I'm waiting for him to update it to include BBCSDL!).

Richard.