Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert IPv4 dotted quad into four decimal values
#3
If all you need to do is break it up into byte values, then something simple like this:

Code: (Select All)
_Font _LoadFont("courbd.ttf", 32, "monospace")




Do
    Input "Enter quad decimal IP multicast group ->", addr$

    GetIPv4 addr$, a, b, c, d
    Print a, b, c, d
Loop until addr$ = ""
SYSTEM

Sub GetIPv4 (temp$, a1, a2, a3, a4)
    text$ = temp$
    GoSub find_v
    a1 = V
    GoSub find_v
    a2 = V
    GoSub find_v
    a3 = V
    GoSub find_v
    a4 = V
    Exit Sub


    find_v:
    p = InStr(text$, ".")
    If p <> 0 Then
        V = Val(Left$(text$, p))
        text$ = Mid$(text$, p + 1)
    Else
        V = Val(text$)
    End If
    Return
End Sub


(And you could simplify that even more, if you just passed it an array to store the values and then ran it in a simple FOR loop.)
Reply


Messages In This Thread
RE: Convert IPv4 dotted quad into four decimal values - by SMcNeill - 09-02-2022, 10:41 AM



Users browsing this thread: 1 Guest(s)