graph loop with non-functional keypressed .

program graph_loop;
uses
crt,graph;
var
count : integer;
color : word;
eks,why,rad,lo_x,hi_x,lo_y,hi_y,inc_x,inc_y: integer;
GD,GM : integer;
trip : boolean;
ch : char;
begin

GD := detect;
initgraph(GD,GM,'');
if graphresult <> grok then
halt(1);

randomize;

count := 0;
lo_x := getmaxx div 2;
lo_y := getmaxy div 2;
hi_x := 1;
hi_y := 1;
inc_X := 1;
inc_y := 1;



repeat

color := 1 + random(15);
setcolor(color);


if lo_x < 21 then
begin
lo_x := getmaxx div 2;
lo_y := getmaxy div 2;
hi_x := 1;
hi_y := 1;
end;

hi_x := hi_x + (inc_x * 2);
hi_y := hi_y + (inc_y * 2);
lo_x := lo_x - inc_x;
lo_y := lo_y - inc_y;

eks := lo_x + random(hi_x);
why := lo_y + random(hi_y);

rad := 1 + random(20);
circle(eks,why,rad);
delay(100);
inc(count);
until (count > 100) or (keypressed);

readln;
cleardevice;
closegraph;

end.


Comments

  • Is nothing wrong with it, just change the [b]readln;[/b] to [b]readkey;[/b]
  • hello
    No, changing readln to readkey dosn't get me out of the running
    loop. I have a lot of old p'grms that use "if keypressed then ch :=
    readkey" and such in animation loops and never had trouble. I have
    a freebyte free download of Pascal. Might it be lame?
  • : hello
    : No, changing readln to readkey dosn't get me out of the running
    : loop. I have a lot of old p'grms that use "if keypressed then ch :=
    : readkey" and such in animation loops and never had trouble. I have
    : a freebyte free download of Pascal. Might it be lame?
    :

    It works fine on my TP7 installation, so that's a possibility. You could try running it from DosBox, see if it helps.
  • [code][/code]


    program graph_lp;

    uses crt,graph;
    var
    eks,why,rad : integer;

    count : integer;

    GD,GM : integer;

    begin

    {*******
    I think I might have a lame freebyte Pascal download. I've Written
    things like the second version and had them work with Pascal 4.
    I tried it from the command line feature and it runs the same - to
    the count while ignoring keypressed. I've seen some Pascal 7s for
    sale on Amazon for a resonable price but they're DOS. and I don't
    know if they'll work with win xp. Comments welcome.

    **********}

    {VVVVVVVVVVVVVVVVVVVVVV keypressed works VVVVVVVVVVVVVVVVVVV}
    count := 1;
    eks := 40;
    why := 40;
    repeat
    gotoxy(eks,why);
    write('circle');
    inc(count);
    delay(100);
    until (count = 100) or (keypressed);
    readln;

    {VVVVVVVVVVVVVVVVVVVV keypressed not so much VVVVVVVVVVVVVVV}

    { GD := detect;
    initgraph(GD,GM,'');
    if graphresult <> grok then
    halt(1);


    count := 1;

    eks := getmaxx div 2;
    why := getmaxy div 2;
    repeat
    setcolor(7);
    circle(eks,why,rad);
    inc(count);
    rad := count;
    delay(100);
    until (Count > 100) or (keypressed);
    readln;
    closegraph; }
    end.


  • My BP7 works fine under Win XP, no issues whatsoever... but I wouldn't spend money on it since it so outdated. Free Pascal on the other hand is up to date, it can handle on code as well and doesn't cost a penny.
  • _ATEX_
    My mistake. What I have is Free Pascal Intel/i386. Sorry. I
    should keep better track of where I've been. If you think I
    shouldn't have this problem with this download,should I try downloading it again?
    Front 1's



  • Doesn't hurt to download again, just don't forget to backup your PAS files before. Include this as 1st line in your code [b]{$mode tp}[/b] to force the compiler to work in Turbo Pascal mode.
  • _ATEX_
    Tried "$mode tp" as first line in working program. Got
    "ordinal const" error when compileing. Meaningfull? Screw up?
    Will repeat download and see if that makes a difference.
    Front1sdog

  • : Tried "$mode tp" as first line in working program. Got
    : "ordinal const" error when compileing. Meaningfull? Screw up?
    : Will repeat download and see if that makes a difference.
    : Front1sdog
    :

    Did you put the "$mode tp" in curly brackets ? >>> {$mode tp}

  • _ATEX_
    Yes. Curly brackets compile and run. P'grm runs same.(no keypressed).
    Can't imagine a flawed download that would do this and still
    run.
    Will re-down load (and save pas files) and let you know what.
    If still problem,what pascal would you get?
    Front1sdog

    Re-downloaded Free Pascal. No change. Could be something else?


  • : Will re-down load (and save pas files) and let you know what.
    : If still problem,what pascal would you get?
    : Front1sdog
    :
    : Re-downloaded Free Pascal. No change. Could be something else?
    :
    :

    Graph and Crt are there for backward compatibility only, they don't work as expected, also I noticed that Graph is working very slow (i guess is being emulated somehow). Download Wingraph and Wincrt instead from here: http://math.ubbcluj.ro/~sberinde/wingraph/wingraph.zip It comes with demo programs, full source and documentation as well.

  • This post has been deleted.
  • _ATEX_
    Will do those down loads.
    Also,was poking around with my problem and discovered (I think) that the difficulty isn't keypressed or CRT. The thing goes num to the keyboard in graph mode.
    Thankyou for your attention. I've been reading the files on this down load and I think It's a potentially good version.
    Front_1's
    And again.
    Did the down loads. The docs don't seem to have much on
    installing. Programs can't find. Open the box and put with other units? Advise please.I feel we're getting close. I'm suprised you think the graphics are slugish. Compared to what I'm used to they zip.
    Front_1's
  • : Did the down loads. The docs don't seem to have much on
    : installing. Programs can't find. Open the box and put with other
    : units? Advise please.I feel we're getting close. I'm suprised you
    : think the graphics are slugish. Compared to what I'm used to they
    : zip.
    : Front_1's
    :

    Either copy the contents of the "bin" folder where your units are located or compile the sources yourself.
  • No joy. but I'm likly doing something wrong. I can't find a source
    to compile. I've copied units in several different ways without sucess. when I try to compile with wingraph I get a fail and the notice "loading c:FPc2.4.unitsi386-win32wingraph.ppu " and
    "ppu invalid version ". I have demos using wingraph that look fine
    and are in the same path as my IDE.
    I can compile using winmouse without trouble.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories