CALL/de

(Difference between revisions)
Jump to: navigation, search
((**COPIED FROM ENGLISH PAGE**) =)
(Remarks)
Line 23: Line 23:
  
 
| valign="top" width="100%" style="width: 308px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 308px; border: 1px solid rgb(0, 0, 0);" |  
Any BASCOM variable or constant.
+
BASCOM-Variable oder Konstante.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 30: Line 30:
  
 
| valign="top" width="100%" style="width: 308px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 308px; border: 1px solid rgb(0, 0, 0);" |  
Any BASCOM variable or constant.
+
BASCOM-Variable oder Konstante.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 37: Line 37:
  
 
| valign="top" width="100%" style="width: 308px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 308px; border: 1px solid rgb(0, 0, 0);" |  
Name of the subroutine. In this case Test.
+
Name der Subroutine. In diesem Fall Test.
  
 
|}
 
|}
Line 43: Line 43:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
You can call sub routines with or without passing parameters.
+
Mann kann Subroutinen mit oder ohne Parameterübergabe aufrufen.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
It is important that the SUB routine is DECLARED before you make the CALL to the subroutine. Of course the number of declared parameters must match the number of passed parameters.
+
Es ist wichtig, dass die Subroutine deklariert wird bevor sie aufgerufen wird. Natürlich muss die Anzahl der deklarierten Parameter mit der Anzahl der übergebenen Parameter übereinstimmt.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 53: Line 53:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
It is also important that when you pass constants to a SUB routine, you must DECLARE these parameters with the BYVAL argument.
+
Es ist außerdem wichtig, dass die Parameter bei Übergabe von Konstanten mit BYVAL deklariert werden.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
With the CALL statement, you can call a procedure or subroutine.
+
Mit dem CALL-Befehl kann man Prozeduren und Subroutinen aufrufen.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
For example: Call Test2
+
Zum Beispiel: Call Test2
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 67: Line 67:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
The call statement enables you to implement your own statements.
+
Der CALL-Befehl ermöglicht es, eigene Befehle zu definieren.
  
You don't have to use the CALL statement:
+
MAn muss CALL nicht explizit schreiben:
  
Test2 will also call subroutine test2
+
Test2 ruft ebenfalls die Subroutine test2 auf.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
Line 77: Line 77:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
When you don't supply the CALL statement, you must leave out the parenthesis.
+
Wenn man CALL nicht explizit schreibt dann müssen die Klammern weggelassen werden.
  
So Call Routine(x,y,z) must be written as Routine x,y,x
+
Also muss  Call Routine(x,y,z)   geschrieben werden als    Routine x,y,x
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Unlike normal SUB programs called with the GOSUB statement, the CALL statement enables you to pass variables to a SUB routine that may be local to the SUB.
+
Im Gegensatz zu normalen Unterprogrammen die mit GOSUB aufgerufen werden erlaubt der CALL-Befehl die Übergabe von Parametern.
  
 
&nbsp;
 
&nbsp;
  
[[File:Notice.jpg|left|Notice.jpg]]By using CONFIG SUBMODE=NEW, you do not need to DECLARE each sub/function.
+
[[File:Notice.jpg|left|Notice.jpg]]Durch Benutzung von CONFIG SUBMODE=NEW braucht man nicht jede Subroutine bzw. Fuktion vorher zu deklarieren.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>

Revision as of 00:32, 13 March 2013

Contents

Funktion

Ruft eine Subroutine auf und führt sie aus.

 

 

Syntax

CALL Test [ (var1, var-n) ]

 

 

Remarks

Var1

BASCOM-Variable oder Konstante.

Var-n

BASCOM-Variable oder Konstante.

Test

Name der Subroutine. In diesem Fall Test.

 

Mann kann Subroutinen mit oder ohne Parameterübergabe aufrufen.

 

Es ist wichtig, dass die Subroutine deklariert wird bevor sie aufgerufen wird. Natürlich muss die Anzahl der deklarierten Parameter mit der Anzahl der übergebenen Parameter übereinstimmt.

 

 

Es ist außerdem wichtig, dass die Parameter bei Übergabe von Konstanten mit BYVAL deklariert werden.

 

Mit dem CALL-Befehl kann man Prozeduren und Subroutinen aufrufen.

 

Zum Beispiel: Call Test2

 

 

Der CALL-Befehl ermöglicht es, eigene Befehle zu definieren.

MAn muss CALL nicht explizit schreiben:

Test2 ruft ebenfalls die Subroutine test2 auf.

 

 

Wenn man CALL nicht explizit schreibt dann müssen die Klammern weggelassen werden.

Also muss Call Routine(x,y,z) geschrieben werden als Routine x,y,x

 

Im Gegensatz zu normalen Unterprogrammen die mit GOSUB aufgerufen werden erlaubt der CALL-Befehl die Übergabe von Parametern.

 

Notice.jpg
Durch Benutzung von CONFIG SUBMODE=NEW braucht man nicht jede Subroutine bzw. Fuktion vorher zu deklarieren.

 

 

See also

DECLARE , SUB , EXIT , FUNCTION , LOCAL , CONFIG SUBMODE

 

 

Example


$regfile = "m48def.dat" ' specify the used micro
$crystal = 8000000 ' used crystal frequency
$baud = 19200 ' use baud rate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
 
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
 
 
Dim A As Byte , B As Byte 'dimension some variables
Declare Sub Test(b1 As Byte , Byval B2 As Byte) 'declare the SUB program
A = 65 'assign a value to variable A
Call Test(a , 5)'call test with parameter A and constant
Test A , 5 'alternative call
Print A 'now print the new value
End
 
Sub Test(b1 As Byte , Byval B2 As Byte) 'use the same variable names as 'the declared one
Print B1 'print it
Print Bcd(b2)
B1 = 10 'reassign the variable
B2 = 15 'reassign the variable
End Sub

Notice.jpg
One important thing to notice is that you can change b2 but that the change will not be reflected to the calling program!

Variable A is changed however.

 

This is the difference between the BYVAL and BYREF argument in the DECLARE ration of the SUB program.

 

When you use BYVAL, this means that you will pass the argument by its value. A copy of the variable is made and passed to the SUB program. So the SUB program can use the value and modify it, but the change will not be reflected to the calling parameter. It would be impossible too when you pass a numeric constant for example.

 

 

If you do not specify BYVAL, BYREF will be used by default and you will pass the address of the variable. So when you reassign B1 in the above example, you are actually changing parameter A.


Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language