Creating a Button with a Bitmap
Button3 uses an Xbasic routine to copy the customer address to the clipboard. Button3 uses a bitmap instead of text to define its purpose.
The following procedure assumes that the developer has opened the form in the Form Editor. Follow these instructions to create a button similar to Button3 :
Place a button on the form.
On the resulting Define Button dialog box click the Define Picture button.
Click the Internal combo box to open it up.
Select the image in the resulting Insert Image dialog box.
Click the System images radio button.
Click the Insert button.
In the Define Picture dialog box click the OK button.
In the Define Button dialog box click the Next button.
Click the Launch Script Editor button to display the Code Editor and to start writing Xbasic code (refer to ((|#Button3_OnPush_Event|Button3 OnPush Event)) ).
Close the Code Editor and save your code.
When the user clicks Button3, Alpha Anywhere runs the following Xbasic code. The code formats the customer name and billing address into a string and copies the string to the system clipboard.
dim tbl as P t = table.current() dim address as C address = trim(tbl.firstname) + " " + trim(tbl.lastname) + crlf() address = address + tbl.bill_address_1 + crlf() if (.not. tbl.bill_address_2.is_blank()) then address = address + tbl.bill_address_2 + crlf() end if address = address + trim(tbl.bill_city) + ", " + trim(tbl.bill_state_region) + " " + tbl.bill_postal_code :clipboard.set_data(address)
The first line creates a pointer variable named tbl to refer to table (and the data) that the Customer Information form displays.
dim tbl as P
Each form is based upon a table (or set). The Customer Information form is based on the Customer table. This line points tbl at the Customer table.
tbl = table.current()
The address will be a character string, so we first dim a variable named c.
dim address as C
Define crlf as a carriage return and line feed.
crlf = chr(13) + chr(10)
Add the firstname and lastname to the address string.
address = trim(tbl.firstname) + " " + trim(tbl.lastname) + crlf
Add address_1 to the address string.
address = address + tbl.bill_address_1 + crlf
If address_2 is not blank, add it to the address string.
if (.not. tbl.bill_address_2.is_blank()) then address = address + tbl.bill_address_2 + crlf end if
Add bill_city, bill_state_region, and bill_postal_code to the address string.
address = address + trim(tbl.bill_city) + ", " + trim(tbl.bill_state_region) + " " + tbl.bill_postal_code
Copy the address string to the clipboard.