1. MS QuickQ(j/k) a quick question
- Posted by Matt Z Nunyabidness <matt1421 at JUNO.COM> Sep 22, 1998
- 418 views
- Last edited Sep 23, 1998
I'm developing a program called PikX that's sorta like my camera.ex and Ralf's txtshow.ex combined. Here's the syntax: ex PikX s/l filename s is for saving pictures, and l is for loading them. Just one problem. It doesn't know you supplied a valid action. Here's the code: PikX.ex: include wildcard.e include get.e include graphics.e include user.e include image.e object cl,fname,action,vc sequence pic integer fn cl=command_line() if length(cl)<4 then puts(1,"\nUsage: ") puts(1,"\nPikX s/l filename") abort(0) end if action=cl[3] fname=cl[4] vc=video_config() action=upper(action) if atom(action)='S' then pic=save_text_image({1,1},{vc[3],vc[4]}) puts(1,"\nOpening "&fname&"...") 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") abort(1) end if print(fn,pic) close(fn) abort(0) elsif atom(action)='L' then puts(1,"Attempting to read from "&fname&"...") 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") abort(2) end if pic=get(fn) if pic=-1 then if pic=GET_EOF then puts(1,"Reached the end of "&fname&" too soon.") abort(3) elsif pic=GET_FAIL then puts(1,fname&" does not contain a valid image.") abort(4) end if end if close(fn) clear_screen() display_text_image({1,1},pic[2]) if wait_key() then end if abort(0) end if puts(1,"\n"&action&": This is not a supported action") Could y'all tell me what's wrong with it? ------------------------------------- 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
2. Re: MS QuickQ(j/k) a quick question
- Posted by Jeffrey Fielding <JJProg at CYBERBURY.NET> Sep 23, 1998
- 389 views
> if atom(action)=3D'S' then I think you misunderstand the use of atom(). atom() gives you a boolean telling you whether something is an atom. There is no need for type casting in Euphoria. You should change this to: if compare(action,"S") =3D 0 then you could also use: if action[1] =3D 'S' then I recommend using the first one since it doesn't matter what action is. Jeffrey Fielding JJProg at cyberbury.net
3. Re: MS QuickQ(j/k) a quick question
- Posted by Hawke <mdeland at NWINFO.NET> Sep 23, 1998
- 403 views
Matt Z Nunyabidness wrote: >I'm developing a program called PikX. Just one problem. >It doesn't know you supplied a valid action. change your code to read: <snip> action=cl[3] fname=cl[4] --let's say byebye before we do anything else if not atom(action) then puts(1,"\n"&action&": This is not a supported action") abort(numberofyourchoosing) end if --let's not do any of this until we know action is valid vc=video_config() action=upper(action) if action='S' then --save file stuff snipped elsif action='L' then --load file stuff snipped end if --end of program okay, now to say why yours didn't work. your lines: if atom(action)='L' then elsif atom(action)='S' then are the culprits. atom() returns a true or false (1 or 0) if the target is/isnt an atom. so what did your lines do? if atom(action)='L' then becomes if (true/false)='L' then now the (true/false) would evaluate to true if you entered "ex pikX l smily.bmp" as the command line and it would evaluate to false if you entered "ex pikX load smily.bmp" as the command line. looking at this closer: first case:"ex pikX l smily.bmp" if atom(action)='L' then --action is an atom,namely 'L', therefore --atom(action) is true (1) and we get: if 1 = 'L' then --as the next test of course the expression 1 = 'L' is FALSE, so the if-then is NOT executed. second case:"ex pikX load smily.bmp" if atom(action)='L' then --action is NOT an atom,namely "LOAD", therefore --atom(action) is false (0) and we get: if 0 = 'L' then and of course the expression 0 = 'L' is ALSO FALSE so the if-then cannot be executed again. did this explanation help or hurt? ;) also, matt, _please_ indent a bit... it *really* helps... *alot* use whatever indention style you like, even single character indenting, as long as blocks line up. you'll help us and perhaps even yourself... hope this helps--Hawke'
4. Re: MS QuickQ(j/k) a quick question
- Posted by Matt Z Nunyabidness <matt1421 at JUNO.COM> Sep 23, 1998
- 412 views
k hawke. cyaz! ------------------------------------- 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 _____________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com Or call Juno at (800) 654-JUNO [654-5866]
5. Re: MS QuickQ(j/k) a quick question
- Posted by Matt Z Nunyabidness <matt1421 at JUNO.COM> Sep 23, 1998
- 386 views
u gave me an idea. the bmp thing, so i added a bitmap 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 _____________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com Or call Juno at (800) 654-JUNO [654-5866]
6. Re: MS QuickQ(j/k) a quick question
- Posted by Noah Smith <nhs6080 at UNIX.TAMU.EDU> Sep 23, 1998
- 387 views
Error handling is for Beta-testers. snortboy