Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Nov 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Need some help / im rusty

    Hey Everyone.. i got a problem and not sure what would be the best route to tackle it.. i attempted it with a batch file but couldn't get it to do what i want.

    what i have is:
    stores with corporate numbers 001-600 i.e. 001, 002,...099,100,101...600..etc.
    and i have a corresponding syntax for ip addresses for the stores so for example:

    Store #: 415
    Has IP's:
    IP1: 100.104.115.227
    IP2: 100.104.115.228
    IP3: 100.104.115.178
    IP4: 100.104.115.179

    *Every store follows this same syntax and has the same ips, only part that changes is the bolded numbers which are the corporate number*

    What I am attempting to accomplish is to run a loop or something that goes through the corporate numbers (001-600) and will output the 4 corresponding IP's for that store.. all to a txt file.. so for example

    ***EXAMPLE OUTPUT***
    Store # 415 Contains
    IP1: 100.104.115.227
    IP2: 100.104.115.228
    IP3: 100.104.115.178
    IP4: 100.104.115.179

    Store # 416 Contains
    IP1: 100.104.115.227
    IP2: 100.104.115.228
    IP3: 100.104.115.178
    IP4: 100.104.115.179

    etc.. all the way to 600

    i guess the breaking up of the corp number for the ip syntax is what was throwing me off.. basically im just after the output, but if someone could pass along the code, id appreciate it! not even sure what the best "language" is to do this with

    EDIT: also, if it's possible, is there a way to put "http://" at the beginning of each ip so that if i copied the text to excel or something it would auto convert it to a hyperlink? that would be sweet!

    Appreciate the consideration!
    -Steve
    Last edited by katalyst; 09-23-2007 at 02:25 AM.
    i'm always learning

  • #2
    Regular Coder
    Join Date
    Feb 2007
    Location
    Seattle
    Posts
    153
    Thanks
    5
    Thanked 9 Times in 9 Posts
    What you are looking for is a script; you should try posting your question in one of those forums. What your after can't be done in html or css, which are strictly presentation languages.

    Gary

  • #3
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    yup can't be done in html/css but can be done in js

    Code:
    <html>
     <head>
    <script>
    window.onload=function(){
    var nl = '\r\n', prefix='http://', b = [];
    for ( var i = 1; i <= 600; i++ ) {
    	var v = ( i < 10 ? '00' : (i < 100 ? '0' : '') ) + i;
    
    	b.push(v.replace(/^(\d)(\d\d)$/, prefix + '100.10$1.1$2.227'));
    	b.push(v.replace(/^(\d)(\d\d)$/, prefix + '100.10$1.1$2.228'));
    	b.push(v.replace(/^(\d)(\d\d)$/, prefix + '100.10$1.1$2.178'));
    	b.push(v.replace(/^(\d)(\d\d)$/, prefix + '100.10$1.1$2.179'));
    }
    
    document.getElementById('test').appendChild(document.createTextNode(b.join(nl)));
    }
    </script>
     </head>
     <body>
    <pre id="test">
    </pre>
     </body>
    </html>
    run once and copy paste
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #4
    New Coder
    Join Date
    Nov 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts
    awww man! that is awesome!
    thanks so much

    gonna study that code. ive never done anythign with javascript. but that is really cool man! really appreciate it!

    im gonna try editing the format

    is there a way i can put a blank line between each store (after every 4 lines) and possibly precede each one with "STORE CORP: *corp number*"?
    i'm always learning


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •