6 Replies Latest reply on Apr 1, 2009 4:36 AM by 738MNdtc

    How to define IPv4 and/or IPv6 number formats?

    738MNdtc

      Title

      How to define IPv4 and/or IPv6 number formats?

      Post

      Greetings.  I have an issue similar to one described here: http://fm.lithium.com/fm/board/message?board.id=FM-en-4&message.id=8536&query.id=133068#M8536 except that I would really like to list all four subsets of the ip address.

       

      10.0.96.1

      10.0.96.2

       

      etc.

       

      I am currently using FM 8.02 Advanced.  Does version 10 have a way to custom define a number format?  I would rather not use my very limited budget to upgrade but given how much we use ip address to identify machines, people and classes of use ....

       

      I am also relatively inexperienced in FM for all that I have used it for years.  I can do really basic scripts and calculations but I am not very sophisticated.  I read some of the responses to the above message and while I sort of understand the theory, when I read the specifics, I kind of lose the connection.  My current work around will probably be to break apart the sets of numbers in a spreadsheet and import those, then write a calculation to create a display field for the whole address.

       

      Thanks.

       

      Thanks.

        • 1. Re: How to define IPv4 and/or IPv6 number formats?
          TSGal

          738MNdtc:

           

          Thank you for your post.

           

          If you have four subsets of the IP address, you can create a calculation field to make all the four subsets a fixed length.  For example, assuming the field with your IP Address is named "IP Address", create a calculation field "CALC IP", resulting in Text, with the formula:

           

          Let (

             [ $p1 = Position ( IP Address ; "." ; 1 ; 1 ) ;

             $p2 = Position ( IP Address ; "." ; 1 ; 2 ) ;

             $p3 = Position ( IP Address ; "." ; 1 ; 3 ) ;

             $x1 = Left ( IP Address ; $p1 - 1 ) ;

             $x2 = Middle ( IP Address ; $p1 + 1 ; $p2 - $p1 - 1 ) ;

             $x3 = Middle ( IP Address ; $p2 + 1 ; $p3 - $p2 - 1 ) ;

             $x4 = Right ( IP Address ; Length ( IP Address ) - $p3 ) ] ;

             Right ( "00" & $x1 ; 3) & "." & Right ( "00" & $x2 ; 3 ) & "." & Right ( "00" & $x3 ; 3 ) & "." & Right ( "00" & $x4 ; 3 )

          )

           

          -----------

           

          For example, using your example:

           

          10.0.96.1 becomes 010.000.096.001

           

          "CALC IP" does not need to be present on the layout.  You only need to sort by "CALC IP" to see the desired results.

           

          Please let me know if you need clarification for any of the above steps.

           

          TSGal

          FileMaker, Inc. 

          • 2. Re: How to define IPv4 and/or IPv6 number formats?
            738MNdtc
              

            That worked like a charm!!  Thank you soooo much.  I almost followed the logic too, () but I would not have been able to come up with that on my own, at least not in the time I have to teach myself these kinds of things.

             

            I am really surprised that it isn't a formatting option for numbers in more software, just like currency, phone numbers, and 5+4 zipcodes.  But I am not a programmer so I probably haven't a clue how hard it is to set that up.

             

            Thanks again.

            • 3. Re: How to define IPv4 and/or IPv6 number formats?
              comment_1
                 I am slightly puzzled by this, because the accepted method of presenting IPv4 addresses is dot-decimal notation - so "10.0.96.1" is already the correct result.
              • 4. Re: How to define IPv4 and/or IPv6 number formats?
                TSGal

                comment:

                 

                Yes, the accepted method of presenting IPv4 addresses is dot-decimal notationand "10.0.96.1" is the correct result.  However, if you sort these fields, you may get something like:

                 

                10.0.96.1

                10.0.96.10

                10.0.96.100

                10.0.96.2

                 

                However, you actually want to put the 10.0.96.2 second.  That was the problem in the original link mentioned, so "CALC IP" was created for sorting purposes only.

                 

                TSGal

                FileMaker, Inc. 

                • 5. Re: How to define IPv4 and/or IPv6 number formats?
                  comment_1
                    

                  I see no mention of a requirement to sort the records. But if that's the issue, then I would simply convert the IP to a simple (i.e. decimal) number:

                   

                  Let ( [
                  octets = Substitute ( IP ; "." ; " " ) ;
                  W = MiddleWords ( octets ; 1 ; 1 ) ;
                  R = MiddleWords ( octets ; 2 ; 1 ) ;
                  G = MiddleWords ( octets ; 3 ; 1 ) ;
                  B = MiddleWords ( octets ; 4 ; 1 )
                  ] ;
                  W * 256^3 + RGB ( R ; G ; B )
                  )

                   




                  • 6. Re: How to define IPv4 and/or IPv6 number formats?
                    738MNdtc
                      

                    I guess I implied that I needed sorting cability.  Sorry.  We use static IP's and certain ips are assigned to machines based on whether their primary user is staff, elementary student or high school student.  It provides a primitive way to define policies regarding our content filter and stuff. 

                     

                    Anyway, the solution from TSGal worked for my needs.  It is nice to know there is another solution though, as it may be a better fit for other people who find this thread.