Help with logic

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rajneesh Chellapilla
    New Member
    • Oct 2008
    • 12

    Help with logic

    This is my code. Its an art project that I am doing as a hobby however I am a little stuck.

    Basically the program counts through unicode characters by using a set timeout feature similar to what you would use for a clock.

    The only problem is that many of the entries are blank so I wanted to write a series of if statemtns that would eliminate the blank spaces based on analysis. For example the counter does nothing till the 12th increment then it shows a symbol. I am trying to make some code to eliminate the blanks but I cant figure out what to do. I commented where I am having trouble.




    Code:
    <html>
    <head>
    <script type="text/javascript">
    var c=0;
    
    var t;
    
    
    function timedCount()
    {
    
    
    String.fromCharCode(c)
    
    document.getElementById('txt').value=String.fromCharCode(c);
    document.getElementById('text').value=c; 
    
    
    //This is the problem area every time I try if statements it doesnt work.
    
    c = c+1;
    d=(d+1);
    e=(e+1);
    t=setTimeout("timedCount()",1000);
    
    
    
    
    
    }
    
    
    
    function stopCount()
    {
    clearTimeout(t);
    }
    
    
    
    
    function resetC()
    { 
     c=10;
     reset();
    
    
    }
    </script>
    
    
    
    
    
    
    
    
    
    
    
    
    <style type="text/css">
    
    .style1 {
       font-family: ;
       
       font-size: 60px;
       color: rgb(0,100,175);
       background-color: #FFFFCC;
       padding: 2px;
       height: 80px;
       width: 100px;
       border: 1px solid #7F9DB9;
    }
    
    .style2 {
       font-family: ;
       font-size: 60px;
       color: rgb(0,100,175);
       background-color: #FFFFCC;
       padding: 2px;
       height: 80px;
       width: 300px;
       border: 1px solid #7F9DB9;
    }
    
    
    
    
    </style>
    
    
    
    
    </head>
    
    <body>
    For God (the Primary Maker of the Good Place Beyond this life)
    <br></br>
    <form>
    <input type="button" value="Start Count" onClick="timedCount()">
    
    
    <input type="text" class="style1" id='txt'><br></br>
    
    <input type="button" value="Stop count!" onClick="stopCount()">
    <input type="button" value="reset" onClick="resetC()">
    <input type="text" class="style2" id='text'>
    
    
    
    </form>
    
    <br></br>
    <br></br>
    <br></br>
    <p>Click on the button above. The the imput will start counting throgh various unicode characters.</p>
    </body>
    
    </html>
    Last edited by acoder; Nov 18 '08, 09:25 AM. Reason: Added [code] tags
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    Sir, can u please tell me what is the purpose of the variable "d" u havent define it in the code

    Regards
    Ramanan Kalirajan

    Comment

    • Rajneesh Chellapilla
      New Member
      • Oct 2008
      • 12

      #3
      Well D and E in crements are there incase I want to because I want to make I am planning the output more than one character 3 to be exact. So for now they are just lett there. I though I eliminated them from the post my apologies.

      Comment

      • RamananKalirajan
        Contributor
        • Mar 2008
        • 608

        #4
        Originally posted by Rajneesh Chellapilla
        Well D and E in crements are there incase I want to because I want to make I am planning the output more than one character 3 to be exact. So for now they are just lett there. I though I eliminated them from the post my apologies.

        Hello, I tried to print the values inside the quotes it is printing some value, you are not getting null values, instead u are getting some spaces. Try the below code

        [HTML]<html>
        <head>
        <script type="text/javascript">
        var c=0;
        var t;
        function timedCount()
        {
        String.fromChar Code(c);
        document.getEle mentById('txt') .value="\' "+String.fromCh arCode(c)+" \'";
        document.getEle mentById('text' ).value=c;
        //This is the problem area every time I try if statements it doesnt work.
        c = c+1;
        //d=(d+1);
        //e=(e+1);
        t=setTimeout("t imedCount()",10 00);
        }
        function stopCount()
        {
        clearTimeout(t) ;
        }
        function resetC()
        {
        c=10;
        reset();
        }
        </script>

        <style type="text/css">
        .style1 {
        font-family: ;

        font-size: 60px;
        color: rgb(0,100,175);
        background-color: #FFFFCC;
        padding: 2px;
        height: 80px;
        width: 100px;
        border: 1px solid #7F9DB9;
        }

        .style2 {
        font-family: ;
        font-size: 60px;
        color: rgb(0,100,175);
        background-color: #FFFFCC;
        padding: 2px;
        height: 80px;
        width: 300px;
        border: 1px solid #7F9DB9;
        }
        </style>
        </head>

        <body>
        For God (the Primary Maker of the Good Place Beyond this life)
        <br></br>
        <form>
        <input type="button" value="Start Count" onClick="timedC ount()">
        <input type="text" class="style1" id='txt'><br></br>
        <input type="button" value="Stop count!" onClick="stopCo unt()">
        <input type="button" value="reset" onClick="resetC ()">
        <input type="text" class="style2" id='text'>

        </form>
        <br></br>
        <br></br>
        <br></br>
        <p>Click on the button above. The the imput will start counting throgh various

        unicode characters.</p>
        </body>

        </html>[/HTML]

        If u want to avoid those things to be displayed u can very well use some js comparison method before printing the value inside the text box. If u need more help just post it in the forum i will try to help u out

        Regards
        Ramanan Kalirajan.

        Comment

        Working...