1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-05 22:50:23 +00:00
QB64-PE/internal/help/_CLIPBOARD$.txt

51 lines
1.7 KiB
Plaintext

The {{KW|_CLIPBOARD$}} function returns the current Operating System's clipboard contents as a [[STRING]].
{{PageSyntax}}
:''result$'' = {{KW|_CLIPBOARD$}}
{{PageDescription}}
* Text returned can contain the entire contents of a copied file or web page.
* The string returned can also contain formatting like CRLF ([[CHR$]](13) + [[CHR$]](10)) end of line characters.
* The clipboard can be used to copy, paste and communicate between running programs.
''Example:'' Passing a string value between two running programs no matter where they are located.
Program1:
{{CodeStart}} '' ''
{{Cl|PRINT}} "Start Program2 to read your text entries! Empty entry quits!"
{{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "Entry program started!" 'set clipboard initially
DO
{{Cl|LINE INPUT}} "Enter some text to send to other program: ", text$
{{Cl|IF...THEN|IF}} text$ = "" {{Cl|THEN}} {{Cl|EXIT DO}}
{{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = text$
{{Cl|LOOP}}
{{Cl|SYSTEM}} '' ''
{{CodeEnd}}
Program2:
{{CodeStart}}
{{Cl|PRINT}} "Enter text in Program1 and this program will read it. Esc key quits!"
DO
text$ = {{Cl|_CLIPBOARD$}} 'function returns clipboard contents
{{Cl|IF...THEN|IF}} {{Cl|LEN}}(text$) {{Cl|THEN}}
{{Cl|PRINT}} text$
{{Cl|_CLIPBOARD$ (statement)|_CLIPBOARD$}} = "" 'clear clipboard after a read
{{Cl|END IF}}
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = {{Cl|CHR$}}(27)
{{Cl|END}} '' ''
{{CodeEnd}}
:''Explanation:'' Compile and run both programs at once to see the interaction. You could also run them on different paths.
{{PageSeeAlso}}
* [[_CLIPBOARD$ (statement)]]
{{PageNavigation}}