Re: Did you know?
Posted: Friday 19th February 2021 4:21am
Code: Select all
int gpioRead(unsigned gpio)
Public Extern gpioRead(iPin As Integer) As Integer
...and execute this function in our Gambas code like this:-
intLevel = gpioRead(intPin)
Code: Select all
int gpioInitialise(void)
Public Extern gpioInitialise() As Integer
...and execute this function in Gambas like this:-intResult = gpioInitialise()
...and then check intResult to see if initialisation was a success or failure.Code: Select all
void gpioTerminate(void)
Public Extern gpioTerminate()
...and execute this routine in Gambas like this:-gpioTerminate()
Private Function GetRandomWord(InMin as Integer, InMax as Integer) As String
Dim TmpStr As String
Dim NewWord As Boolean = False
Dim ExecParam As String
Dim WordCount as Integer = 101000
Dim DictionaryName as string = "american-english"
Repeat
ExecParam = "awk -v lineno=" & Str(Rand(1, WordCount)) & " 'lineno==NR{print;exit}' /usr/share/dict/" & DictionaryName
Shell ExecParam To TmpStr
TmpStr = LCase(TmpStr)
TmpStr = Replace(TmpStr, "'s", "") ' Many of the words in the dictionary have a plural suffix
TmpStr = Replace(TmpStr, "\n", "") ' Remove the 'new line' characters
If Not UsedWords.Exist(TmpStr) Then NewWord = True
If ((Len(TmpStr) < InMin) Or (Len(TmpStr) > InMax)) Then NewWord = False
Until NewWord
UsedWords.Add(TmpStr)
Return TmpStr
End
OMG that's MASSIVELY useful
' Gambas class file
'Fmain Form
Public te As Boolean
Public TxOut As String
Public Sub Form_Open()
FMain.Center
TextBox1.SetFocus
End
Public Sub Button1_Click()
' Setup Variable to Pass to Form2
TxOut = "Variable Sent To Form2"
'Set Form2 Textbox1 to = TextBox1.Text
Form2.TextBox1.Text = TextBox1.Text
'Clear TextBox1 Text
TextBox1.Text = ""
'Set Form2 variable of TxIn to TxOut
Form2.TxIn = TxOut
'Close the main from and open the second window
Me.Close
Form2.Show
End
Public Sub Button2_Click()
Me.Close
End
********************************************************** 'Gambas class file
'Form2 Form
Public TxIn As String
Public Sub Form_Open()
Form2.Center
End
Public Sub Button1_Click()
'Assign the contents of FMain Textbox1 to
'Form2 TextBox2
FMain.TextBox2.Text = TextBox1.Text
'Set FMain TextBox1 to returned text
FMain.TextBox1.Text = "Text was sent and Returned"
'Display the variable from FMain
Message(TxIn)
'Reopen FMain
FMain.Show
Me.Close
End