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
Regular
Posts: 117
Joined: Tue Jul 09, 2024 9:27 am

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: 1206
Joined: Wed Sep 21, 2016 2:22 pm
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
Regular
Posts: 117
Joined: Tue Jul 09, 2024 9:27 am

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 Wed Jul 10, 2024 2:25 am, edited 1 time in total.
User avatar
thatbruce
Regular
Posts: 303
Joined: Sat Sep 04, 2021 11:29 pm
Location: Sitting at my desk in South Australia

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".
sergioabreu
Regular
Posts: 117
Joined: Tue Jul 09, 2024 9:27 am

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

Post by sergioabreu »

cogier wrote: Tue Jul 09, 2024 4:51 pm 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
Regular
Posts: 117
Joined: Tue Jul 09, 2024 9:27 am

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

Post by sergioabreu »

thatbruce wrote: Wed Jul 10, 2024 12:58 am 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