
-----------------------------------
JR
Thu Mar 25, 2004 9:19 am

removing gaps
-----------------------------------
here is my program, and whatever i make a gap it counts it as well, how do i skip the gaps so it wont count it?

var line : string
var a : int
var prec : real
var letters : array 1 .. 26 of int
setscreen ("graphics:500;600")
for z : 1 .. 26
    letters (z) := 0
end for
put "Enter your text"
loop
    get line : *
    for i : 1 .. length (line)
        if line (i) not= ' ' then
            letters ((ord ((line (i))) - 96)) := letters ((ord ((line (i))) - 96)) + 1
        end if
    end for
    put " "
    put "letters", "      ", "precentage"
    for i2 : 1 .. 26
        prec := letters (i2) / length (line) * 100
        put ""
        put chr (96 + i2), " : ", letters (i2), "\t", "\t", round (prec), " % " ..
        a := round (prec)
        exit when i2 = 26
    end for


-----------------------------------
nate
Thu Mar 25, 2004 10:01 am


-----------------------------------
Before the main part of your program put in this code to figure out the length of just the text ignoring the spaces


var length :int

for z : 1..length(line)
         if line(z) not= ' ' then
                 length := length + 1
         end if
end for

So then inseat of using length(line) use the variable length for the length of the characters in the line

-----------------------------------
GUI.GetScrollBarWidth : i
Thu Mar 25, 2004 11:50 am


-----------------------------------
change your code with this and it should work

var line : string 
var a : int 
var prec : real 
var letters : array 1 .. 26 of int 
setscreen ("graphics:500;600") 
for z : 1 .. 26 
    letters (z) := 0 
end for 
put "Enter your text" 
loop 
    get line : * 
    for i : 1 .. length (line) 
        if line (a) not= ' ' then 
            letters ((ord ((line (a))) - 96)) := letters ((ord ((line (i))) - 96)) + 1 
        end if 
    end for  
    put "letters", "      ", "precentage" 
    for i2 : 1 .. 26 
        prec := letters (i2) / length (line) * 100 
        put "" 
        put chr (96 +y21), " : ", letters (i2), "\t", "\t", round (prec), " % " .. 
        a := round (prec) 
        exit when i2 = 26 
    end for 


-----------------------------------
nate
Thu Mar 25, 2004 5:45 pm


-----------------------------------
When you help some1 make sure your code actually works! Did you even test it. IT doesn't even run!

-----------------------------------
JR
Tue Mar 30, 2004 9:27 am


-----------------------------------
so how do i close those gaps?

-----------------------------------
nate
Tue Mar 30, 2004 6:57 pm


-----------------------------------
What do u mean by close the gaps? be more specific 

*just for clarification by gaps you mean spaces?

-----------------------------------
JR
Tue Mar 30, 2004 7:09 pm


-----------------------------------
ok lets say that u type aaa aaa in the program, the program counted the space and made it eaqual to 86% instead of 100 a's. how do i make the program not calculate this space?

-----------------------------------
jonos
Tue Mar 30, 2004 7:59 pm


-----------------------------------
for counter : 1.. length(sentence)
if sentence(counter) not= " " then
letterCount += 1
end if
end for

-----------------------------------
nate
Tue Mar 30, 2004 9:07 pm


-----------------------------------
hahaha, nice spam jonos but just look up the page at like the exact same code! lol, w.e 

Basically JR you need to read the last post by me or jonos. The thing is you don't take spaces away you just ignore them. This board isn't here 2 do ur work just help you at it.

Good Luck
