View previous topic :: View next topic |
Author |
Message |
ario
Joined: 18 Sep 2005 Posts: 1
|
Posted: Sun Sep 18, 2005 8:54 am Post subject: Problem passing parameters to a subroutin in all versions |
|
|
Hi
I have written sub a subroutin for test in bascom avr v1.11.7.3 to v1.11.7.9 but in all versions i cant pass any parametr such az values or references to a sub routin. my test program is here:
$regfile "m8def.dat"
Declare Sub Abc(byval A As Byte)
Abc 123
End
Sub Abc
Print A
End Sub
this program typically must print 123
but it will print 255!
cause the value is realy changed to 255 when it sent to the subroutin.
is that means i cant send any parameter to a subroutin in bascom?
Thank for your replys.
Ario
|
|
Back to top |
|
|
Dibor
Joined: 04 Dec 2004 Posts: 137 Location: ISRAEL
|
Posted: Sun Sep 18, 2005 9:44 am Post subject: |
|
|
Hi.
Checked with v.1.11.7.4
Print 123 !
Looks work. |
|
Back to top |
|
|
Dibor
Joined: 04 Dec 2004 Posts: 137 Location: ISRAEL
|
Posted: Sun Sep 18, 2005 9:52 am Post subject: |
|
|
Hi
Maybe try tis :
$regfile "m8def.dat"
Declare Sub Abc(byval A As Byte)
Call Abc(123)
End
Sub Abc
Print A
End Sub |
|
Back to top |
|
|
oe9vfj
Joined: 17 Jun 2004 Posts: 269 Location: Austria, Hard
|
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Sun Sep 18, 2005 7:24 pm Post subject: |
|
|
hello,
First check your stact that is right.
how I do to work with Sub and function, it works very well, that is typically "Basic" law.
A procedure (SUB) must be declared in the following way:
Dim Pression as Integer, hours as byte 'declaration of the variables
Declare Sub Verification (byval Pression as Integer, hours as byte)
Pression = 255
Print Pression ‘ 255
Call Verification(pression) `call of the procedure
Print Pression ‘ 245
End 'end program attention the sub and function are written after this line!
Sub Verification(pression As Integer, heure as byte) ‘procedure
Pression = Pression - 10
Print Pression ‘imprime 245
Waitms 200 ' etc…
End Sub
I think You forgot that is underlined
JP _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
|