eos and uninitchar. Help?
Author |
Message |
bass_maniac
|
Posted: 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?
Description: |
|
Download |
Filename: |
Picoder.t |
Filesize: |
1.97 KB |
Downloaded: |
177 Time(s) |
Description: |
|
Download |
Filename: |
blank.txt |
Filesize: |
0 Bytes |
Downloaded: |
171 Time(s) |
Description: |
|
Download |
Filename: |
code.txt |
Filesize: |
630 Bytes |
Downloaded: |
180 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
beard0
|
Posted: Sat Oct 15, 2005 5:35 pm Post subject: (No subject) |
|
|
Part of the problem would arise from this:
And part would be that using the pic commands can change colour values in Turing.
|
|
|
|
|
|
bass_maniac
|
Posted: 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
|
Posted: 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
|
Posted: 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
|
Posted: 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.
|
|
|
|
|
|
|
|