# clipb2var

Copies the text data of clipboard.

    clipb2var <strvar> [<offset>]

## Remarks

Copies the text data in clipboard to <strvar>.
If clipboard content is too long, copied data was truncated. (cf. maximum length of a string)

If <offset> is specified, copied string starts offset*511-1 bytes.
When the <offset> is specified not 0, please run the clipb2var command with the offset is nothing or is 0.
When <offset> is not 0, the clipboard content is not current but the content after the <offset> is nothing or 0.

The "clipb2var" command returns one of the following values in the system variable "result":

Value | Meaning
--- | ---
0 | Could not open the clipboard. Or the clipboard content was not a text data. Or the offset value was invalid.
1 | Copying to <strvar> is successful.
2 | Copied string was truncated. If you want to read a truncated data, increment a offset value and execute a clipb2var command again.
3 | Could not allocate a memory to copy a clipboard content.

## Example

    clipb2var data
    messagebox data 'clipboard data'

    ; Load the clipboard data over 511 byte
    ; +------------------------------------------------------------------+
    ; |  1024 bytes clipboard text                                       |
    ; +------------------------------------------------------------------+
    ; +-------------------------+--------------------------+-------------+
    ; | (1) 511 bytes           | (2) 511 bytes            | (3) 2 bytes |
    ; +-------------------------+--------------------------+-------------+

    clipb2var data ; (1) stores into the data and the result is 2.
    messagebox data 'clipboard data 1'

    clipb2var data 1 ; (2) stores into the data and the result is 2.
    messagebox data 'clipboard data 2'

    clipb2var data 2 ; (3) stores into the data and the result is 1.
    messagebox data 'clipboard data 3'

    clipb2var data 3 ; the data is empty and the result is 0.
    messagebox data 'clipboard data 4'

    ; read a clipboard content and write it to a file.
    fileopen fp 'clipboard.txt' 0
    if result <> 0 end

    offset = 0
    do
        clipb2var buff offset
        if result > 0 filewrite fp buff
        offset = offset + 1
    loop while result = 2

    fileclose fp