Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

graph loop with non-functional keypressed .

front1sdogfront1sdog Posts: 32Member
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.


«1

Comments

  • _Atex__Atex_ Posts: 163Member
    Is nothing wrong with it, just change the [b]readln;[/b] to [b]readkey;[/b]
  • front1sdogfront1sdog Posts: 32Member
    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?
  • _Atex__Atex_ Posts: 163Member
    : 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.
  • front1sdogfront1sdog Posts: 32Member
    [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.


  • _Atex__Atex_ Posts: 163Member
    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.
  • front1sdogfront1sdog Posts: 32Member
    _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


  • _Atex__Atex_ Posts: 163Member

    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.
  • front1sdogfront1sdog Posts: 32Member
    _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
  • _Atex__Atex_ Posts: 163Member

    : 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}

  • front1sdogfront1sdog Posts: 32Member
    _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?

«1
Sign In or Register to comment.