buon di a tutti , sto provando a prendere l indirizzo getway di default , da gambas , ho guardato un po ma vedo che nella perte network a solo per creare socket etc , ma non per recuperare i dati , (se mi sbaglio correggetemi), allora l ho fatto tramite shell con questo comando Shell "(/sbin/ip route | awk '/default/ { print $3 }')" To GetwayIP
il problema è che quando vado ad addizionare infondo al getway una stringa tipo questa Print Getway & "/24 " , ho come risultato anziche 192.168.1.1/24 su una riga 192.168.1.1 e sulla seconda /24 ho provato anche a togliere a GetwayIP i ritorni a capo con questa stringa "echo " & GetwayIP & " | tr -d '\r'" To Getway
anon c'è stao bene
qualcuno può darmi qualche dritta???
grazie infinite
ciao
Ad ogni modo per eliminare il valore &h0A (ritorno a capo) alle due estremità di una stringa, devi utilizzare la funzione nativa di Gambas "Trim( )".
Più specificatamente questa funzione elimina "tutti gli spazi bianchi sia a sinistra che a destra di un'espressione stringa"; laddove per "spazi bianchi" si intende: "quei caratteri con codice ASCII inferiiore a 33".
Da provare:
Public Sub Main()
Dim GetwayIP, senzaspazibianchi As String
Dim bb As Byte[]
Dim b As Byte
Shell "(/sbin/ip route | awk '/default/ { print $3 }')" To GetwayIP
bb = Byte[].FromString(GetwayIP)
For Each b In bb
Print Hex(b, 2)
Next
Print GetwayIP & "/24 "
Print "\n\n"
senzaspazibianchi = Trim(GetwayIP)
bb = Byte[].FromString(senzaspazibianchi)
For Each b In bb
Print Hex(b, 2)
Next
Print senzaspazibianchi & "/24 "
End