1. paramaters problem
- Posted by Matt Z Nunyabidness <matt1421 at JUNO.COM>
Sep 30, 1998
-
Last edited Oct 01, 1998
yup. pikx.ex. I tried to make it support filenames with spaces, but it
won't work. If i specify c:\windows\straw mat.bmp as the filename,
pikx.ex think's it's c:\windows\strawbitmapc:\windows\strawbitmap.bmp. If
i specify the filename without paces, it says
c:\windows\strawmat.bmpc:\windows\strawmat.bmp.
Here's my code:
--PikX.ex by matt1421 at juno.com
--At the moment, busted
with trace
--trace(1)
include wildcard.e
include get.e
include graphics.e
include user.e
include image.e
object cl,fname,action,vc,lines,prgname,pal,pixels,bname,mode,buf
sequence pic
integer fn
cl=command_line()
prgname=cl[2]
if not find(".ex",prgname) then
prgname=prgname&".ex"
end if
if length(cl)<4 then
puts(1,"PikX v1.0")
text_color(12)
puts(1,"\nU")
text_color(15)
puts(1,"S")
text_color(9)
puts(1,"A")
text_color(7)
puts(1,"ge: ex PikX load/save/bitmap filename")
puts(1,"\nUse load to load a picture made with PikX")
puts(1,"\nUse save to save a picture")
puts(1,"\nUse bitmap to load and display a .BMP file")
puts(1,"\nfilename is the file to read from or write to")
puts(1,"\n\nSyntax:\nex pikx load/save/bitmap filename")
puts(1,"\n\nload\tLoad a picture made with Camera or PikX")
puts(1,". Doesn't really matter what it \n\twas made with(MUST BE
SEQUENCE FORMAT)")
puts(1,"\n\nsave\tSave a picture\nbitmap\tLoad a Windows Bitmap")
abort(0)
end if
action=cl[3]
fname=cl[4]
vc=video_config()
action=upper(action)
if not compare(action,"SAVE") then
pic=save_text_image({1,1},{vc[3],vc[4]})
puts(1,"\nAttempting to save to "&fname&"...")
if not compare(fname,prgname) then
puts(1,"I can't let you overwrite me.")
abort(0)
end if
fn=open(trim(fname),"w")
if fn=-1 then
puts(1,"\nThere was an error opening "&fname)
puts(1,"\nWhat might have occured is an access denied error")
puts(1,"\nError code: 1")
abort(1)
end if
print(fn,pic)
close(fn)
abort(0)
elsif not compare(action,"LOAD") then
puts(1,"Attempting to read from "&fname&"...")
if not compare(fname,prgname) then
puts(1,"I'm not an image!")
abort(0)
end if
fn=open(fname,"r")
if fn=-1 then
puts(1,"\nThere was an error loading "&fname)
puts(1,"\nWhat might have occured is a file not found")
puts(1,"\nPlease check your typing and try again")
puts(1,"\nError code: 2")
abort(2)
end if
pic=get(fn)
if pic[1]=GET_EOF then
puts(1,"Reached the end of "&fname&" too soon.")
puts(1,"\nError code: 3")
abort(3)
elsif pic[1]=GET_FAIL then
puts(1,fname&" does not contain a valid image.")
puts(1,"\nError code: 4")
abort(4)
end if
close(fn)
clear_screen()
display_text_image({1,1},pic[2])
if wait_key() then
end if
vc=video_config()
lines=vc[3]
position(lines-1,1)
abort(0)
elsif not compare(action,"BITMAP") then
if length(cl)>3 then
for z= 3 to length(cl) do
buf=cl[z]
fname=fname&buf
end for
end if
bname=read_bitmap(fname)
if atom(bname) then
if bname=BMP_UNSUPPORTED_FORMAT then
puts(1,"\nSorry, not a supported format")
puts(1,"\nError code: 6")
abort(6)
elsif bname=BMP_UNEXPECTED_EOF then
puts(1,"\nReached an unexpected End-Of-File marker")
puts(1,"\nError code: 5")
abort(5)
elsif bname=BMP_OPEN_FAILED then
puts(1,"\nPikX was unable to load "&fname)
puts(1,"\nWhat might have just occurred is a file not found")
puts(1,"\nerror. Please check your typing and try again.")
puts(1,"\nError code: 2")
abort(2)
end if
end if
pal=bname[1]
pal=pal/4
pixels=bname[2]
bname={}
if length(pal)> 16 then
mode=257
else
mode=18
end if
if graphics_mode(mode) then
end if
all_palette(pal)
display_image({0,0},pixels)
if wait_key() then
end if
if graphics_mode(-1) then
end if
abort(0)
end if
puts(1,"\n"&action&": This is not a supported action")
___________________________
When it comes to programming languages, Euphoria is a cut above -
matt1278 at juno.com and matt1421 at juno.com(and soon to be
irisnmatt at prodigy.net. Then again, maybe not) Euphoria programmer
Web users: <A HREF=mailto:"matt1421 at juno.com">matt1421 at juno.com</A> or <A