Delphi: Breaking an IP down into a Difrent variable for each ocet

Discussion in 'Software' started by iamien, Apr 5, 2003.

  1. iamien

    iamien Cptn "Eh!"

    Well dont know how many delphi people we have around here but i know theres me and Goldfish. Heres my procedure

    { you may wish to store OC1-4 into global variables rather then into Local, if you wish to use them outside this procedure}
    Procedure ChopIP;

    var
    Msg, UpTi, DTi, oc1, oc2, oc3, oc4 : string;
    loc1, loc2, loc3, MsgL : integer;
    begin

    Msg := edit1.text; // Store the IP in Edit1.text to a variable
    MsgL :=length(msg); // Store then Length of the IP for later use

    oc1 := trim(Copy(Msg, 1 , Pos('.', msg)- 1)); //Takes the IP and stores the first occet into Oc1
    Loc1 := length(oc1);
    delete(msg, 1, loc1 + 1) ; //Deletes first occet and its '.'

    oc2 := trim(copy(msg, 1, pos('.', msg) - 1 ));//Takes the IP and stores the second occet into Oc2
    loc2 := length(oc2);
    delete(msg, 1, Loc2 + 1); // Deletes second occet and its '.'

    oc3 := trim(copy(msg, 1, pos('.', msg) - 1 )); //Takes the IP and stores Third ocet
    Loc3 := length(oc3);
    delete(msg, 1, Loc3 + 1); // Deletes third occet and its '.'

    oc4 := trim(copy(msg, 1, msgl )); // Stores Fourth occet to Oc4
    {Now you have each occet stored
    into variables, you can increment,
    test them, each indiviualy.
    But before you can do that you
    will need to apply StrToInt to each
    occet so that it can be added too.
    DO not try to apply StrToInt in the above while applying
    it to the Oc variables as you cannot get the length of
    and integer and it is criticle to this procedure
    to be able to determin the length of each Occet}
    end;
     
  2. goldfish

    goldfish Lt. Sushi.DC

    ah, was looking for that!

    ty v much
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds