fb:porticula NoPaste
Code-Vorschlag (COM-Port und formatierter SINGLE-Wert)
Uploader: | Sebastian |
Datum/Zeit: | 20.09.2009 11:04:37 |
'Code-Vorschlag zu http://forum.qbasic.at/viewtopic.php?t=6771
'Für FreeBASIC 0.20.0 (Windows)
Declare Function WertFormatieren(ByVal Wert As Single) As String
#include "string.bi"
dim sw_eingabe as single
dim wert as single
dim t as string * 2
open Com "com10:9600,n,8,1,cs0,cd0,ds0,rs" for random as #1
do
cls
if err <> 0 Then
print "Error opening USB/COM Port"
sleep
end
end if
locate 3,3
input" Eingabe Sollwert...: ", sw_eingabe
print #1,"S" 'senden der Anfrage Sollwert
sleep 200,0
print #1, WertFormatieren(sw_eingabe)
sleep 200,0
print #1,"C"
input #1,wert
print " Im Regler "; wert
input " Eingabe y = weiter / n = Ende ", t
if LCASE(t) <> "y" then
exit do
End If
Loop
Close #1
End
Function WertFormatieren(ByVal Wert As Single) As String
Dim F As String
F=Trim(Format(Wert,"##0.00"))
For i As Integer = 0 To Len(F)-1
If F[i] = 44 Then F[i] = 46 'Komma durch Punkt ersetzen
Next i
Return F
End Function