Salve a tutti sto creando 2 programmi uno in m-shell e l'altro in visual basic per permettere al computer e al mio 6600 di scriversi dei messaggi in stile chat.
la parte in vb è perfettamente funzionante e invia quello che deve inviare, mentre quella in m-shell riceve solamente e non trasmette, dopo varie prove ho scoperto il perché: per qualche oscuro motivo quello che faccio inviare dal programma in m-shell non viene inviato finché il programma non termina.
per farvi capire posto i listati:
use bt, io, ui
ui.menu("Service",["Send"]);
dev=bt.select();
s=bt.conn(dev["adr"], [4353]);
io.writeln(s, "*START*");
string="";
while equal(string,"*END*")=false do
if equal(string,"*NOMSG*")=false then
print "Pc>> ",string;
end;
if string="*NOMSG*" then
cmd=ui.cmd(500);
if equal(cmd,null)=false then
io.writeln(s, "*W8*");
new=ui.query("", "Nuovo Messaggio", "");
io.writeln(s, new);
print "Me>> ",new;
end;
end;
string=io.readln(s);
end;
io.close(s);
print "Programma terminato!";
e se vi può servire o vi incuriosisce posto anche il codice del programma in visual basic...
Private Sub Form_Load()
On Error GoTo ErrHandler
MSComm1.CommPort = 6 'nel mio computer al cell è associata la porta COM6
MSComm1.Settings = "9600,n,8,1"
MSComm1.PortOpen = True
Exit Sub
ErrHandler:
MsgBox "Errore Porta di comunicazione", vbCritical
End Sub
Private Sub Form_Unload(Cancel As Integer)
MSComm1.Output = "*END*" & vbNewLine
MSComm1.PortOpen = False
End Sub
Private Sub JeweledButton1_Click()
If Text1.Text <> "" Then
RichTextBox1.Text = RichTextBox1.Text & "Me>> " & Text1.Text & vbNewLine
MSComm1.Output = Text1.Text & vbNewLine
Text1.Text = ""
End If
End Sub
Private Sub MSComm1_OnComm()
Dim Rx$
Rx$ = MSComm1.Input
If Len(Rx$) Then
'If InStr(1, Rx$, "*START*") = 1 Then
If Rx$ = ("*START*" & vbCrLf) Then
JeweledButton1.Enabled = True
Timer1.Enabled = True
ElseIf Rx$ = ("*W8*" & vbCrLf) Then
Timer1.Enabled = False
Else
RichTextBox1.Text = RichTextBox1.Text & "Cell>> " & Rx$ & vbNewLine
If Timer1.Enabled = False Then Timer1.Enabled = True
End If
End If
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If Text1.Text <> "" And KeyCode = vbKeyReturn Then
RichTextBox1.Text = RichTextBox1.Text & "Me>> " & Text1.Text & vbNewLine
MSComm1.Output = Text1.Text & vbNewLine
Text1.Text = ""
End If
End Sub
Private Sub Timer1_Timer()
MSComm1.Output = "*NOMSG*" & vbNewLine
End Sub
EDIT:
ah il form visual basic deve avere una RichTextBox(inclusa di base in windows, sostituibile con una textbox multiline), una textbox, un jeweled button(sostituibile con un normalissimo pulsante), un timer(enabled=false,interval=1500) e una mscomm(inclusa di base in windows, e serve per gestire le porte COM)