LB Booster
Programming >> Liberty BASIC language >> Copy & Paste
http://lbb.conforums.com/index.cgi?board=lblang&action=display&num=1454939489

Copy & Paste
Post by Cheemag on Feb 8th, 2016, 12:51pm

GA,

Is there any way to implement copy and paste inside LBB compiled programmes?

Liberty Basic allows it but not, apparently, LBB.

--

Cheemag


Re: Copy & Paste
Post by Richard Russell on Feb 8th, 2016, 2:25pm

on Feb 8th, 2016, 12:51pm, Cheemag wrote:
Liberty Basic allows it but not, apparently, LBB.

That is not correct. LBB's texteditor control supports the !copy and !paste commands just like LB's does. The texteditor also supports user-initiated copy & paste either via the Edit menu or using keyboard shortcuts (Ctrl+C for copy, Ctrl+V for paste). Some of the other GUI controls, e.g. the textbox and the combobox, also support those keyboard shortcuts.

In fact I don't know of any way in which LBB differs from LB in respect of the clipboard, except of course in the mainwin (a difference which is specifically called out in the LBB documentation). The mainwin is principally intended for use as a debugging aid, e.g. to log diagnostic output, and the copy-to-clipboard hotkey Ctrl+Tab is hopefully adequate for that use. In a compiled program there should normally be a NOMAINWIN statement anyway.

Richard.

Re: Copy & Paste
Post by Cheemag on Feb 10th, 2016, 11:53am

on Feb 8th, 2016, 2:25pm, Richard Russell wrote:
That is not correct. LBB's texteditor control supports the !copy and !paste commands just like LB's does. The texteditor also supports user-initiated copy & paste either via the Edit menu or using keyboard shortcuts (Ctrl+C for copy, Ctrl+V for paste). Some of the other GUI controls, e.g. the textbox and the combobox, also support those keyboard shortcuts.


I didn't mean in the LBB text editor. In a very simple text-only proggy written in LBB you cannot use copy and paste within the simple programme (whether or not you compile it).

In LB you can use the copy & paste functions.

Quote:
In fact I don't know of any way in which LBB differs from LB in respect of the clipboard, except of course in the mainwin (a difference which is specifically called out in the LBB documentation). The mainwin is principally intended for use as a debugging aid, e.g. to log diagnostic output, and the copy-to-clipboard hotkey Ctrl+Tab is hopefully adequate for that use. In a compiled program there should normally be a NOMAINWIN statement anyway.

Richard.


In LBB it doesn't get as far as the clipboard - you cannot select text at all in a simple programme.

Regards
Cheemag

Re: Copy & Paste
Post by tsh73 on Feb 10th, 2016, 12:46pm

if " simple text-only proggy" refers to mainwin, then LB/JB does not allow paste.
That is you can pretend you paste - but Input will not read it.
Re: Copy & Paste
Post by Richard Russell on Feb 10th, 2016, 1:37pm

on Feb 10th, 2016, 11:53am, Cheemag wrote:
In LB you can use the copy & paste functions.

As Anatoly says paste does not work in the JB/LB mainwin. When your program is requesting input from the user (using the INPUT statement) pressing Ctrl+V appears to paste in text, but nothing arrives in the string received by your BASIC program! The paste operation is illusory. sad

On the contrary in LBB you can paste into the INPUT statement using Ctrl+V and the pasted text successfully arrives in the returned string. smiley

So as far as paste is concerned the truth is the opposite of what you claimed: it doesn't work in the JB/LB mainwin (other than visually) but it does work in the LBB mainwin (in the INPUT statement)!

Quote:
In LBB it doesn't get as far as the clipboard - you cannot select text at all in a simple programme.

You cannot select text in the LBB mainwin, but as I said you can copy the entire contents of the mainwin (so long as it hasn't scrolled off the top) into the clipboard. You can always paste that text into a regular text editor and extract a section of it if you need to.

The LBB mainwin does not fully emulate the LB mainwin, and it was never intended to. The LBB mainwin is in fact the underlying BBC BASIC mainwin, and therefore it supports many things that the LB mainwin doesn't. You can display colored text in the LBB mainwin, you can display Unicode text in the LBB mainwin and you can display graphics in the LBB mainwin!

If you want a window which has File and Edit menus and which supports text selection, copy and paste, use a TEXT window or a TEXTEDITOR control.

Richard.

Re: Copy & Paste
Post by Cheemag on Feb 13th, 2016, 3:19pm

on Feb 10th, 2016, 12:46pm, tsh73 wrote:
if " simple text-only proggy" refers to mainwin, then LB/JB does not allow paste.
That is you can pretend you paste - but Input will not read it.


I'm afraid it does: you can cut, copy and paste with the mouse in a prog compiled with Liberty Basic 4 (v4.04) in Windows 7. I've just checked it. Marked and context-menu-copied string goes into my clipboard and can be pasted normally.

Try it !

Regards

Cheemag

Re: Copy & Paste
Post by tsh73 on Feb 13th, 2016, 3:46pm

Doesn't work for me, LB 404, Win7
Code:
print "hello there"
input a$
print "got";a$
input "press enter";a$ 
 

I run it - select "there" - make Copy from context menu - click after (?) - select "paste" from context meny
It visibly paste but program prints "got" that is got nothing.
EDIT
(and it was compiled EXE)
Re: Copy & Paste
Post by Richard Russell on Feb 13th, 2016, 5:43pm

on Feb 13th, 2016, 3:19pm, Cheemag wrote:
I'm afraid it does: you can cut, copy and paste with the mouse in a prog compiled with Liberty Basic 4 (v4.04) in Windows 7. I've just checked it.

It doesn't work for me either; checked using the code Anatoly listed, using LB 4.5.0.

Are you sure you're not being misled by the fact that it appears to work (visually), even though nothing arrives in the variable returned from INPUT?

It's true that you can't paste using the mouse in LBB, but you can by typing Ctrl+V and, unlike JB/LB, it actually works!

Richard.

Re: Copy & Paste
Post by Cheemag on Feb 22nd, 2016, 8:05pm

on Feb 13th, 2016, 5:43pm, Richard Russell wrote:
It doesn't work for me either; checked using the code Anatoly listed, using LB 4.5.0.

Are you sure you're not being misled by the fact that it appears to work (visually), even though nothing arrives in the variable returned from INPUT?

It's true that you can't paste using the mouse in LBB, but you can by typing Ctrl+V and, unlike JB/LB, it actually works!

Richard.


Something odd here. I assure you it works in LB v4.04 in Windows 7 Home Premium 64-bit.

I ran the 'hello world' programme above and was able to copy 'hello world' and paste it into a text editor using the mouse to mark it then right-click 'Copy'.

It also worked compiled and had menu-bar items 'File' and 'Edit' in the window in both compiled and interpreted versions. The 'Edit' dropdown could be used to copy to the clipboard after marking.

Must emphasise I'm talking about Liberty Basic and not LBB. I asked because I wondered why I had this facility in LB but not LBB.

Regards,

Cheemag.

PS I'll post the window output as graphic if you don't believe me ! (If I can find out how to post it ...)



Re: Copy & Paste
Post by Richard Russell on Feb 23rd, 2016, 09:16am

on Feb 22nd, 2016, 8:05pm, Cheemag wrote:
I ran the 'hello world' programme above and was able to copy 'hello world' and paste it into a text editor using the mouse to mark it then right-click 'Copy'.

Yes, that is copying from the mainwin (not pasting to the mainwin which is what Anatoly and I have been talking about). As documented in the LBB manual, copying from the LBB mainwin works differently from JB/LB - you have to use the Ctrl+Tab hotkey to do that.

Quote:
It also worked compiled and had menu-bar items 'File' and 'Edit' in the window in both compiled and interpreted versions. The 'Edit' dropdown could be used to copy to the clipboard after marking.

Again, that is a documented difference between LB and LBB. Look in the LBB help file under 'Compatibility':

"7. The mainwin can hold only about 84 lines of text; if more lines are output the remainder will be 'scrolled off' the top of the window and lost. Also, the mainwin has no menu. You can copy the contents of the mainwin onto the clipboard by typing Ctrl+Tab".

Quote:
I asked because I wondered why I had this facility in LB but not LBB.

I explained that before. Because the Liberty BASIC mainwin is intended primarily as a debugging aid, and because you are recommended to include a NOMAINWIN statement in a finalized compiled program, it seemed to me (and it still does) that providing a greater degree of compatibility with LB - which would have been difficult - was not justified. Making the LBB mainwin compatible with the BBC BASIC mainwin was considerably easier and provides facilities that LB doesn't (such as colored text, Unicode, graphics and font changes).

The point which you still seem to be missing is that pasting into the mainwin works properly in LBB (using the Ctrl+V keyboard shortcut) but doesn't work in LB. This is a significant limitation of LB because when entering a response to an INPUT statement it appears that you can paste in text but in fact you can't.

Richard.