Is it possible to test functions in gambas console?

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
sergioabreu
Posts: 25
Joined: Tuesday 9th July 2024 9:27am

Is it possible to test functions in gambas console?

Post by sergioabreu »

If I create a Public Function in a module. Is it possible to test it using the gambas console?
I tried an got "Unknow symbol"
User avatar
cogier
Site Admin
Posts: 1140
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Is it possible to test functions in gambas console?

Post by cogier »

If I understand this correctly, you could type the word Stop just after any Dim statements in your function. Run the program in the IDE. The program will stop when it gets to the Stop command. You can use the [F8] key to step through each command to see exactly what's happening. Gambas will display the error when it arrises.
sergioabreu
Posts: 25
Joined: Tuesday 9th July 2024 9:27am

Re: Is it possible to test functions in gambas console?

Post by sergioabreu »

Actually is other thing:
I want to test a brand new function in console without having to run a program.
Lets suppose a function with a string as argument, Visual Basic (if I am not wrong) allowed to do in console:

? newfunction("test string")

and see the result in console. I think gambas doesn't have this feature.
Last edited by sergioabreu on Wednesday 10th July 2024 2:25am, edited 1 time in total.
User avatar
thatbruce
Posts: 195
Joined: Saturday 4th September 2021 11:29pm

Re: Is it possible to test functions in gambas console?

Post by thatbruce »

The function would have to be entirely atomic and could not rely on anything that had occurred before in the program, especially instantiation of any object involved.
So it wold be of little use generally.
What cogier said is how "it is done here".
Have you ever noticed that software is never advertised using the adjective "spreadable".
sergioabreu
Posts: 25
Joined: Tuesday 9th July 2024 9:27am

Re: Is it possible to test functions in gambas console?

Post by sergioabreu »

cogier wrote: Tuesday 9th July 2024 4:51pm If I understand this correctly, you could type the word Stop just after any Dim statements in your function. Run the program in the IDE. The program will stop when it gets to the Stop command. You can use the [F8] key to step through each command to see exactly what's happening. Gambas will display the error when it arrises.
;) You are correct. Usually the function depends of the Module/Form to work. So the breakpoint is a way to test it, pausing the program. Thank you for the tip.
sergioabreu
Posts: 25
Joined: Tuesday 9th July 2024 9:27am

Re: Is it possible to test functions in gambas console?

Post by sergioabreu »

thatbruce wrote: Wednesday 10th July 2024 12:58am The function would have to be entirely atomic and could not rely on anything that had occurred before in the program, especially instantiation of any object involved.
So it wold be of little use generally.
What cogier said is how "it is done here".
You both are right. In gambas the functions are glued with the form/Module and the only way to test it is to run and breakpoint to allow a console testing. Just did it and worked fine. :geek:
Post Reply