Connecting Tech Pros Worldwide Help | Site Map

Help with logic

Newbie
 
Join Date: Oct 2008
Posts: 12
#1: Nov 17 '08
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.




Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. var c=0;
  5.  
  6. var t;
  7.  
  8.  
  9. function timedCount()
  10. {
  11.  
  12.  
  13. String.fromCharCode(c)
  14.  
  15. document.getElementById('txt').value=String.fromCharCode(c);
  16. document.getElementById('text').value=c; 
  17.  
  18.  
  19. //This is the problem area every time I try if statements it doesnt work.
  20.  
  21. c = c+1;
  22. d=(d+1);
  23. e=(e+1);
  24. t=setTimeout("timedCount()",1000);
  25.  
  26.  
  27.  
  28.  
  29.  
  30. }
  31.  
  32.  
  33.  
  34. function stopCount()
  35. {
  36. clearTimeout(t);
  37. }
  38.  
  39.  
  40.  
  41.  
  42. function resetC()
  43.  c=10;
  44.  reset();
  45.  
  46.  
  47. }
  48. </script>
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. <style type="text/css">
  62.  
  63. .style1 {
  64.    font-family: ;
  65.  
  66.    font-size: 60px;
  67.    color: rgb(0,100,175);
  68.    background-color: #FFFFCC;
  69.    padding: 2px;
  70.    height: 80px;
  71.    width: 100px;
  72.    border: 1px solid #7F9DB9;
  73. }
  74.  
  75. .style2 {
  76.    font-family: ;
  77.    font-size: 60px;
  78.    color: rgb(0,100,175);
  79.    background-color: #FFFFCC;
  80.    padding: 2px;
  81.    height: 80px;
  82.    width: 300px;
  83.    border: 1px solid #7F9DB9;
  84. }
  85.  
  86.  
  87.  
  88.  
  89. </style>
  90.  
  91.  
  92.  
  93.  
  94. </head>
  95.  
  96. <body>
  97. For God (the Primary Maker of the Good Place Beyond this life)
  98. <br></br>
  99. <form>
  100. <input type="button" value="Start Count" onClick="timedCount()">
  101.  
  102.  
  103. <input type="text" class="style1" id='txt'><br></br>
  104.  
  105. <input type="button" value="Stop count!" onClick="stopCount()">
  106. <input type="button" value="reset" onClick="resetC()">
  107. <input type="text" class="style2" id='text'>
  108.  
  109.  
  110.  
  111. </form>
  112.  
  113. <br></br>
  114. <br></br>
  115. <br></br>
  116. <p>Click on the button above. The the imput will start counting throgh various unicode characters.</p>
  117. </body>
  118.  
  119. </html>
RamananKalirajan's Avatar
Needs Regular Fix
 
Join Date: Mar 2008
Location: Chennai - India
Posts: 348
#2: Nov 17 '08

re: Help with logic


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

Regards
Ramanan Kalirajan
Newbie
 
Join Date: Oct 2008
Posts: 12
#3: Nov 17 '08

re: Help with logic


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.
RamananKalirajan's Avatar
Needs Regular Fix
 
Join Date: Mar 2008
Location: Chennai - India
Posts: 348
#4: Nov 18 '08

re: Help with logic


Quote:

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.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>[/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.
Reply