So will "FIXME:" and "NOTE:".
Did you know?
- Got2BeFree
- Posts: 111
- Joined: Saturday 26th November 2016 2:52am
- Location: Lost
Re: Did you know?
sholzy
You may start a journey with certain goals or objectives, but things don’t always turn out the way you expect them to.
You may start a journey with certain goals or objectives, but things don’t always turn out the way you expect them to.
Re: Did you know? ...the Recent Projects screen
I'm probably the last person to discover this, but I sometimes end up with 2 copies of a project in different folders, and then don't know which one to open from the Recent Projects screen.
I don't know why the project path is not shown on-screen, as there is plenty of space for it.
However, if you simply hold the mouse over the project icon, a tool-tip will pop-up and display the path.
I don't know why the project path is not shown on-screen, as there is plenty of space for it.
However, if you simply hold the mouse over the project icon, a tool-tip will pop-up and display the path.
- cogier
- Site Admin
- Posts: 1157
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Did you know?
No I did not know that one. Very useful as I also have run into the same issue. Thanks.
- BruceSteers
- Posts: 1790
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Did you know?
I almost submitted a commit with a change to enable this and spotted it already does it when editing the code lol
had that issue soooo many times.
had that issue soooo many times.
If at first you don't succeed , try doing something differently.
BruceS
BruceS
Re: Did you know? ...Basic declarations in C Libraries
level: Intermediate
category: External C Libraries
subject: Basic declarations in C Libraries
Not everyone would have learnt the C programming language on their path to Gambas greatness.
But when attempting to use a C library in Gambas, you need to understand how routines & functions are declared in C.
Here are a few examples taken from the RaspberryPi pigpio library:-
This declaration literally means that "this function will return an integer (int) and requires an unsigned integer (unsigned) argument for a variable named gpio"
So we declare this in Gambas like this:-
Example 2:-
In C the keyword "void" means nothing. So this declaration literally means that "this function will return an integer (int) and does not require any arguments (void)".
So we declare this in Gambas like this:-
Example 3:-
This declaration literally means that "this routine will not return anything (void) and does not require any arguments (void)".
So we declare this in Gambas like this:-
category: External C Libraries
subject: Basic declarations in C Libraries
Not everyone would have learnt the C programming language on their path to Gambas greatness.
But when attempting to use a C library in Gambas, you need to understand how routines & functions are declared in C.
Here are a few examples taken from the RaspberryPi pigpio library:-
Code: Select all
int gpioRead(unsigned gpio)
So we declare this in Gambas like this:-
Public Extern gpioRead(iPin As Integer) As Integer
...and execute this function in our Gambas code like this:-
intLevel = gpioRead(intPin)
Example 2:-
Code: Select all
int gpioInitialise(void)
So we declare this in Gambas like this:-
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.Example 3:-
Code: Select all
void gpioTerminate(void)
So we declare this in Gambas like this:-
Public Extern gpioTerminate()
...and execute this routine in Gambas like this:-gpioTerminate()
- Quincunxian
- Posts: 181
- Joined: Sunday 25th June 2017 12:14am
- Location: Western Australia
Did you know? - How to get a Random Word.
You can use this function to get a random word from your preferred dictionary.
If you check the /usr/share/dict/ area, you can find other dictionaries you can use.
Please check the actual lines(word count) in the dictionary and adjust the WordCount variable accordingly.
UsedWords[ ] is a string array that holds words that have already been used. You should clear this when start a new sequence/game.
{Million to one chances happen one in ten times: Sir Terry Pratchett}
If you check the /usr/share/dict/ area, you can find other dictionaries you can use.
Please check the actual lines(word count) in the dictionary and adjust the WordCount variable accordingly.
UsedWords[ ] is a string array that holds words that have already been used. You should clear this when start a new sequence/game.
{Million to one chances happen one in ten times: Sir Terry Pratchett}
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
Cheers - Quin.
I code therefore I am
I code therefore I am
Re: Did you know?
DYK, that pressing [Ctrl] + H or [Ctrl] + J while editing a class will open a split screen. Comes in handy when you need to reference back to a different area of the class your working on which has scrolled off of your screen.
- BruceSteers
- Posts: 1790
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Did you know?
OMG that's MASSIVELY useful
Thank you I had no idea it did that
If at first you don't succeed , try doing something differently.
BruceS
BruceS
Re: Did you know?
Was playing around with passing variables between forms and discovered how to do it without using global variables. You need to make the text boxes public for this to work.
' 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