VAL/de

(Difference between revisions)
Jump to: navigation, search
((**COPIED FROM ENGLISH PAGE**) =)
(Remarks)
Line 15: Line 15:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
= <span class="f_Header">Remarks</span> =
+
= <span class="f_Header">Anmerkungen</span> =
 
<div style="padding: 0px; margin: 0px 0px 0px 4px;">
 
<div style="padding: 0px; margin: 0px 0px 0px 4px;">
 
{| width="567" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
 
{| width="567" cellspacing="0" cellpadding="1" border="1" style="border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;"
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
 
| valign="top" width="13%" style="width: 70px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="13%" style="width: 70px; border: 1px solid rgb(0, 0, 0);" |  
Var
+
var
  
 
| valign="top" width="100%" style="width: 488px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 488px; border: 1px solid rgb(0, 0, 0);" |  
A numeric variable that is assigned with the value of s.
+
Numerische Variable der der Wert von s zugewiesen wird.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
 
| valign="top" width="13%" style="width: 70px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="13%" style="width: 70px; border: 1px solid rgb(0, 0, 0);" |  
S
+
s
  
 
| valign="top" width="100%" style="width: 488px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 488px; border: 1px solid rgb(0, 0, 0);" |  
Variable of the string type.
+
Zeichenkettenvariable.
  
 
|}
 
|}
Line 36: Line 36:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
It depends on the variable type which conversion routine will be used. Single and Double conversion will take more code space.
+
Es hängt vom Variablentyp ab welche Konvertierungsroutinen intern benutzt werden. Single- und Double-Konvertierungen benötigen mehr Programmspeicherplatz.
  
When you use INPUT, internal the compiler also uses the VAL routines.
+
Bei Verwendung von INPUT verwendet der Compiler intern auch die VAL-Funktion.
  
In order to safe code, there are different conversion routines. For example BINVAL and HEXVAL are separate routines.
+
Um Code zu sparen gibt es andere Umwandlungsroutinen wie zum Beispiel BINVAL und HEXVAL.
  
While they could be added to the compiler, it would mean a certain overhead as they might never be needed.
+
Sie könnten dem Compiler hinzugefügt werden aber das würde Overhead bedeuten weil sie möglicherweise nie benötigt werden.
  
With strings as input or the INPUT statement, the string is dynamic and so all conversion routines would be needed.
+
Mit Zeichenketten als Eingabe oder beim INPUT Befehl ist die Zeichenkette dynamisch und deshalb würden alle Konvertierungs-Routinen benötigt werden.
  
 
&nbsp;
 
&nbsp;
  
The VAL() conversion routine does not check for illegal characters. If you use them you get a wrong result or 0.
+
Die VAL()-Funktion prüft nicht auf ungültige Zeichen. Wenn sie benutzt werden dann ergibt das falsche Ergebnisse oder 0.
  
If you want to check for illegal characters you can add a constant named _VALCHECK to your code with a value of 1.
+
Falls Sie eine Prüfung auf ungültige Zeichen wünschen dann können Sie die Konstante _VALCHECK mit dem Wert 1 hinzufügen.
  
This will include some code that will set the ERR variable to 0 or 1. If illegal characters are found, ERR will return 1.
+
Dadurch wird Code erzeugt, der eine ERR-Variable auf 0 oder 1 setzt. Wenn ungültige Zeichen erkannt werden dann gibt ERR 1 zurück.
  
Since VAL is used for the INPUT statement too, this will also work for the INPUT statement.
+
Da VAL auch beim INPUT-Befehl benutzt wird geht das auch beim INPUT-Befehl.
  
 
&nbsp;
 
&nbsp;

Revision as of 23:34, 1 March 2013

Contents

Funktion

Wandelt eine Zeichenkettendarstellung einer Zahl in eine Zahl um.

 

 

Syntax

var = VAL( s)

 

 

Anmerkungen

var

Numerische Variable der der Wert von s zugewiesen wird.

s

Zeichenkettenvariable.

 

Es hängt vom Variablentyp ab welche Konvertierungsroutinen intern benutzt werden. Single- und Double-Konvertierungen benötigen mehr Programmspeicherplatz.

Bei Verwendung von INPUT verwendet der Compiler intern auch die VAL-Funktion.

Um Code zu sparen gibt es andere Umwandlungsroutinen wie zum Beispiel BINVAL und HEXVAL.

Sie könnten dem Compiler hinzugefügt werden aber das würde Overhead bedeuten weil sie möglicherweise nie benötigt werden.

Mit Zeichenketten als Eingabe oder beim INPUT Befehl ist die Zeichenkette dynamisch und deshalb würden alle Konvertierungs-Routinen benötigt werden.

 

Die VAL()-Funktion prüft nicht auf ungültige Zeichen. Wenn sie benutzt werden dann ergibt das falsche Ergebnisse oder 0.

Falls Sie eine Prüfung auf ungültige Zeichen wünschen dann können Sie die Konstante _VALCHECK mit dem Wert 1 hinzufügen.

Dadurch wird Code erzeugt, der eine ERR-Variable auf 0 oder 1 setzt. Wenn ungültige Zeichen erkannt werden dann gibt ERR 1 zurück.

Da VAL auch beim INPUT-Befehl benutzt wird geht das auch beim INPUT-Befehl.

 

 

 

See also

STR , HEXVAL , HEX , BIN , BINVAL , STR2DIGITS

 

 

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 , S As String * 10
S = "123"
A = Val(s) 'convert string
Print A ' 123
 
S = "12345678"
Dim L As Long
L = Val(s)
Print L
End


Example 2


$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
 
Const _VALCHECK=1 ' TEST VAL()
Dim A As Byte , S As String * 10
S = "123"
A = Val(s) 'convert string
Print A ; " ERR:" ; Err ' 123
 
S = "1234a5678"
Dim L As Long
L = Val(s)
Print L ; " ERR:" ; Err
End

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