The example package


Contents



Overview




The package example_package provides some components that will be used in the source code examples of the HBasic documentation. This package includes two components:

Nogui
A component with no visible widget at runtime which only provides a simple interface
XButton
A button like widget component which is derived from the QT QPushButton

Both components only use a very minimalistic interface to work as simple as possible and may therefore also be used as a template for new packages.



Component Nogui





The following methods may be used with a component of type file:

Open
Open a file for reading or writing
Close
Close a file
Eof
Check if end of file has been reached.
read( long )
read values in ASCII format from file
readline
read until end of line has been reached.
write
Write values as ASCII text to a file
writeline
Write a string with CR to file
get
Get a binary value from a file
getstr
Get String of special length from file
getxstr
get string from file in extended format
put
Write binary value to file
putstr
Write string to file
putxstr
Write string in extended format to file.




Component XButton







File example



The following example opens a file in write-mode and writes the numbers from 1 to 20 to it.


Public f As file
Public i As Long

Sub button1_clicked()
f.open( "test.dat", "w" )
i = 1
While i < 20 Do
f.write( "Value = "+str(i))
i = i + 1
Wend
f.close()
End Sub

Example ex_comp_file.bas: Open file and write data to it