QUOTE (imipak @ Jan 7 2009, 07:55 PM)
(Edit - thanks sci44, that's really thrown down the gauntlet..! Does your snippet need additional code to actually write a file? What would it produce, a bitmap? )
As is, it just plots straight to a DOS-mode screen in glorious clunky DOS VGA graphics, but if you hit shift-PrtSc (printscreen) then Alt-Tab to Windows, you can paste the screenshot into Paint & save a Bmp. Or do it more properly with VisualBasic, VB script, FreeBasic, or for that matter Perl, C (my choice), etc etc. Nice thing about Qbasic is everyone has it/can get it, and very small short progs with no "overhead" code can do useful things - its nice for posting short examples up on forums, etc.
To write to a PGM file, from line 5 (FOR y=....) onwards replace with:-
OPEN fil$+".pgm" FOR OUTPUT AS 2
PRINT #2,"P2" : PRINT #2,mx;my : PRINT #2, 256 : REM put max no colours for that 256..
FOR y = 1 TO my: FOR x = 1 TO mx
INPUT #1, v
REM Do calculation/manipulation of (v) here..
PRINT #2, v;
NEXT x: NEXT y
CLOSE 1 : CLOSE 2
---------------
Although thats untested..
Edit: seems to work ok..
Just put the manipulation you want in the middle, ie:
IF v > 7 THEN v = 1 ELSE v = 0
etc etc..