Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 eos and uninitchar. Help?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bass_maniac




PostPosted: Sat Oct 15, 2005 3:10 pm   Post subject: eos and uninitchar. Help?

Briefly, my program takes a txt file and converts every character with an ordinal value between 32 and 126 into a colour and prints a dot of that colour on the screen. It then saves a picture of that file. You can also decode the picture by having it look at the colour of the dots and converting them back into characters. Look at the file for more info.

The problem is converting them back. I keep getting the error "char converted to string is EOS or uninitchar." I looked this up in the help file, but I don't understand what I've done wrong. None of the colours should have an ord of 0 or 128, because my program only excepts characters between 32 and 126.

Any ideas on what I'm doing wrong here?



Picoder.t
 Description:
The program

Download
 Filename:  Picoder.t
 Filesize:  1.97 KB
 Downloaded:  169 Time(s)


blank.txt
 Description:
a blank txt file

Download
 Filename:  blank.txt
 Filesize:  0 Bytes
 Downloaded:  156 Time(s)


code.txt
 Description:
the stuff to be coded

Download
 Filename:  code.txt
 Filesize:  630 Bytes
 Downloaded:  170 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
beard0




PostPosted: Sat Oct 15, 2005 5:35 pm   Post subject: (No subject)

Part of the problem would arise from this:
Turing:
for i : 32 .. 126
    drawdot (0, 0, i)
    if whatdotcolour (0, 0) not= i then
        put "Hello - ", i , " = ",whatdotcolour (0, 0),"?!"
    end if
end for

And part would be that using the pic commands can change colour values in Turing.
bass_maniac




PostPosted: Sun Oct 16, 2005 6:52 pm   Post subject: (No subject)

Uh oh. Why do I feel like my program is falling apart before my eyes?

Is there any way around the pic commands changing colour values? Why would Turing assign two values to one colour (ie 52 and 11)?
Cervantes




PostPosted: Sun Oct 16, 2005 7:16 pm   Post subject: (No subject)

bass_maniac wrote:
Why would Turing assign two values to one colour (ie 52 and 11)?

Explanation
GlobeTrotter




PostPosted: Sun Oct 16, 2005 7:17 pm   Post subject: (No subject)

Here's a function I just wrote that will always give you the biggest possible whatdotcolor. If you draw something 40, it will return whatdotcolor as 40, if you draw it as 12, it will also return it as 40. This is what you would want, I believe.

code:

var BadColours : flexible array 1 .. 0 of
    record
        putCol : int
        getCol : int
    end record

for i : 0 .. maxcolor
    drawdot (0, 0, i)
    if whatdotcolour (0, 0) ~= i then
        new BadColours, upper (BadColours) + 1
        BadColours (upper (BadColours)).putCol := i
        BadColours (upper (BadColours)).getCol := whatdotcolour (0, 0)
    end if
end for

cls

function FixedWhatDotColour (x, y : int) : int
    var tempcol : int
    tempcol := whatdotcolor (x, y)
    for i : lower (BadColours) .. upper (BadColours)
        if tempcol = BadColours (i).getCol then
            tempcol := max (tempcol, BadColours (i).putCol)
        end if
    end for
    result tempcol
end FixedWhatDotColour


Put that near the beginning of your code, and anytime you used whatdotcolor in your program replace it with FixedWhatDotColour.
bass_maniac




PostPosted: Mon Oct 17, 2005 10:57 am   Post subject: (No subject)

Thanks GlobeTrotter. That worked perfectly. I finished my program and I'll post it over in the Submitted forum.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: