Board index » delphi » No More Insert Mode

No More Insert Mode

To all my friends onshore,

       I am having problems.  I am attempting to make an ascii art game, a simple version of Microsoft's Nibbles.  I have a border around the
outside, and whenever I write something inside the box, part of it gets indented.  Can anyone help?

Daniel Morton

 

Re:No More Insert Mode


Does the problem disappear when you make the right side
one column to the left?
Use gotoxy, use write instead of writeln.

Please Daniel, this is no fun. =(

I have read 3 messages coming from you, all stating:
I want... how can I...

At least show some of the code you have so far. The problem then
becomes much clearer and you learn much more about Pascal

Assuming you have a BASIC background,
Pascal needs a different approach.
It's not good programming practice to simply
'translate' every statement you know.

Making a procedure to act upon both a string and an integer,
depending on the type - simply because it's possible in BASIC -
is not a good way to start with.

Tips:
- Divide the process into smaller parts.
- Refine these parts into new smaller parts
- Try to complete one part at a time, not the whole thing at once
- Make every procedure do _one_ specific thing.
- Use comments to refer to code that you will construct later.
- First work on the essential parts, try to make it look nicer
when everything else is working.

Example:

program trying_to_make_it_work;

uses Crt;

const max_column=79; {use comments here}
          max_line=20
          score_line=22     {output lie for score}
          input_line=24

type str1=string[80];
         prompt=string[30];

         play_field=array[1..max_line, 1..max_column] of char;
         players=(no_one, first, second, the_pc);

         play_status_rec=record
                                          whos_turn: players;
                                          turns_left,
                                          errors_made,
                                          other_stuff: integer
                                     end;

var PF: play_field;
      PSR:play_status

(* ------- input procedures ----------- *)

procedure read_anyting(ps:prompt; var rstr:str1);
{parameters:  in: ps - state what you want,
                      out: rstr - give back what user typed

Quote
}

begin
     write(prompt); readln(rstr);
end; {read_anything}

procedure read_string(pps:prompt; var rrstr:str1)
var ok:boolean;
begin
     ok:=true;
     repeat
        read_anything
(*
        if rrstr ....
        'check for illegal characters'
*)
     until ok
     rstr:=rrstr
end; {read_string}

(*
procedure read_integer(ps:prompt; lb, ub:integer; var
ii:integer);
{parameters: in: ps      - message to display
                             lb, ub - lower and upper bound of
expected integer
                      out: ii - an integer within defined bounds
lb and ub.

Quote
}

begin
repeat:
   display prompt, read a string
   check for digits (and minus sign)
   if ok:
      convert to integer
   check for boundaries
until is_integer and boundaries_ok
end; {read_integer}
*)

(* --------- play_game procedures ----------  *)
procedure do_input;
var s:str1;
begin
     read_anything('Give me some input: ', s);
end; {do_input}

{main program}
begin
(*
display_intro
setup_screen
play_game
ask_for_more
display_bye
*)
end.

Daniel Morton heeft geschreven in bericht
<1103_958174501@default>...

Quote
>To all my friends onshore,

>       I am having problems.  I am attempting to make an ascii

art game, a simple version of Microsoft's Nibbles.  I have a
border around the
Quote
>outside, and whenever I write something inside the box, part of

it gets indented.  Can anyone help?
Quote

>Daniel Morton

Other Threads