Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Problem passing parameters to a subroutin in all versions

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
ario

Bascom Member



Joined: 18 Sep 2005
Posts: 1

PostPosted: Sun Sep 18, 2005 8:54 am    Post subject: Problem passing parameters to a subroutin in all versions Reply with quote

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?
Rolling Eyes
Thank for your replys.
Ario
Back to top
View user's profile
Dibor

Bascom Member



Joined: 04 Dec 2004
Posts: 125
Location: ISRAEL

israel.gif
PostPosted: Sun Sep 18, 2005 9:44 am    Post subject: Reply with quote

Hi.

Checked with v.1.11.7.4

Print 123 !

Looks work.
Back to top
View user's profile MSN Messenger
Dibor

Bascom Member



Joined: 04 Dec 2004
Posts: 125
Location: ISRAEL

israel.gif
PostPosted: Sun Sep 18, 2005 9:52 am    Post subject: Reply with quote

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
View user's profile MSN Messenger
oe9vfj

Moderator



Joined: 17 Jun 2004
Posts: 269
Location: Austria, Hard

austria.gif
PostPosted: Sun Sep 18, 2005 11:31 am    Post subject: Reply with quote

HI,

You can pass parameter at this way.
Most problem at this topic are caused of to low stack settings.

Increase your stack sizes, especially those for Frame size.

Check also thread http://www.mcselec.com/forum/viewtopic.php?t=791&highlight=

_________________
regards Josef

DOS - File System for BASCOM-AVR on http://members.aon.at/voegel
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 923
Location: France

france.gif
PostPosted: Sun Sep 18, 2005 7:24 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum