Is it possible to test functions in gambas console?

Post

Posted
Rating:
#1 (In Topic #1268)
Regular
sergioabreu is in the usergroup ‘Regular’
 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"
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
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.
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
sergioabreu is in the usergroup ‘Regular’
 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.
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
 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".

Online now: No Back to the top

Post

Posted
Rating:
#5
Regular
sergioabreu is in the usergroup ‘Regular’

cogier said

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.
Online now: No Back to the top

Post

Posted
Rating:
#6
Regular
sergioabreu is in the usergroup ‘Regular’

thatbruce said

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:
Online now: No Back to the top
1 guest and 0 members have just viewed this.