Computer Science Canada

Decoding program

Author:  pwnapple [ Sun Dec 18, 2005 4:26 pm ]
Post subject:  Decoding program

I've got the decoding part ok, but I need some help with the output

Here's what i have so far

put "Enter a coded message with all letters offsetted by the number of"
put "characters within the first word. "
get code : *

offsetkey := index (code, " ") - 1
%decoding
message := ""
message2 := ""
msglength := 40
for aa : 1 .. length (code)
number := ord (code (aa))

if not number = 63 and not number = 33 and not number = 44 and not number = 46 and not number = 58 and not number = 59 and not number = 45 and not number = 32 then

for xx : 1 .. offsetkey
number := ord (code (aa)) - 1
if number < 65 then
number := 90
elsif number < 97 and number > 90 then
number := 122
end if
end for
end if

%OUTPUT

locate (14, 20)
if aa < msglength + 1 then
message := message + chr (number)
end if
if aa > msglength then
put message
message2 := message2 + chr (number)
locate (15, 20)
put message2
end if
end for



I need to make it so that when 40 characters are exceeded it goes onto the next line, no matter how many characters you have.

The output cannot exceed 40 characters per line, if it does it goes to the next line.

No word can be broken (the word can't be started on a line and continued on the next)

Author:  Cervantes [ Sun Dec 18, 2005 4:35 pm ]
Post subject: 

First, you'll need to know how to search for a space. Check out the String Manipulation tutorial. You'll find a link to it in the Turing Walkthrough.


: