Xbasic

FILE.WRITEB Function

Syntax

Bytes_Written as N = file_pointer.WriteB(B data)

Arguments

dataBinary

A variable or expression containing binary data.

Returns

Bytes_WrittenNumeric

Returns the number of bytes written to the file.

Description

Write blob to file.

Discussion

The .WRITEB() method transfers the contents of a blob to the location of the current file pointer in the open file referenced by the file object pointer. This function is useful for writing binary data to a file.

Example 

The following example converts a bitmap created in memory into JPEG format, then writes it to file.

dim saveb as B
dim savej as B
dim fptr as P
ui_bitmap_create("test", width, height)
ui_bitmap_draw("test",<<%code%
...
%code%)
saveb = ui_bitmap_save("test")
savej = bitmap_to_jpeg(saveb)
fptr = file.create("c:\was\chart.jpg", FILE_RW_EXCLUSIVE)
fptr.writeb(savej)
fptr.close()

See Also