Computer Science Canada

paint prog help

Author:  abzoni [ Sun Dec 11, 2005 12:20 pm ]
Post subject:  paint prog help

hi, im currently workin on my paint prog *BIG PROJECT* and im basicly done except i cant get the program to add on a ".bmp" to the end of the filename when the user's saving. heres what i have so far:
if filename (* -3 .. *) not= ".bmp" then
filename := filename + ".bmp"
end if
any help would be appreciated! thx!

Author:  do_pete [ Sun Dec 11, 2005 12:27 pm ]
Post subject: 

this is the source code forum not the help forum

Author:  Paul [ Sun Dec 11, 2005 1:53 pm ]
Post subject: 

That looks like it would do, what are you having problems with exactly?

Author:  TheXploder [ Sun Dec 11, 2005 7:08 pm ]
Post subject: 

shouldn't it be '-4'?
code:

if filename (* -4 .. *) not= ".bmp" then
   filename := filename + ".bmp"
end if


p.s. yay paint I did that for my final project in gr.10

Author:  we64 [ Sun Dec 11, 2005 7:16 pm ]
Post subject: 

yeah, TheXploder had one of the best paint program around in Turing. Ask him for advice.

Author:  Paul [ Sun Dec 11, 2005 8:15 pm ]
Post subject: 

TheXploder wrote:
shouldn't it be '-4'?
code:

if filename (* -4 .. *) not= ".bmp" then
   filename := filename + ".bmp"
end if


p.s. yay paint I did that for my final project in gr.10


... no
say the string is "paulbian", "n" would be the 8th letter of the string, getting the last 4 would be *-3, because 8-3=5, and 5..8 is "bian", 4 letters.

Author:  Paul [ Sun Dec 11, 2005 9:03 pm ]
Post subject: 

Here's something I put together:
code:

%Saving picture

setscreen ("graphics: 300; 300")

var FileName : string := ""

Draw.Oval (maxx div 2, maxy div 2, 50, 50, brightred)
var PicID := Pic.New (0, 0, maxx, maxy)

cls
put "File name: " ..
get FileName : *

if length (FileName) >= 4 then

    if FileName (* -3 .. *) not= ".bmp" then
        FileName += ".bmp"
    end if

else
    FileName += ".bmp"

end if

Pic.Save (PicID, FileName)



Hope it helps.

Author:  abzoni [ Tue Dec 13, 2005 11:03 am ]
Post subject:  thx alot!:D

i finished my proj w/ your suggestions and ive been told im prolly gonna get perfect.

thx for all your help guys:D


: