Recent

Author Topic: pls help in pascal programmation error  (Read 4237 times)

vdsba

  • Newbie
  • Posts: 1
pls help in pascal programmation error
« on: August 28, 2012, 11:45:51 pm »
Hello, i want to execute this pascal file with Lazarus, there is errors that i don't know how to solve.
pease help me.

Code: [Select]
program septembre ;
uses crt;
var nom,choix:string;
var tabnom: array [ 1..10 ] of string ;
var tabpre: array [ 1..10 ] of string ;
var tabrue: array [ 1..10 ] of string ;
var tabnum: array [ 1..10 ] of string ;
var tabcode: array [ 1..10 ] of string ;
var tabloc: array [ 1..10 ] of string ;
var tabpay: array [ 1..10 ] of string ;
var tabtel: array [ 1..10 ] of string ;
var tabdat: array [ 1..10 ] of string ;
var tabref: array [ 1..10 ] of string ;
var tablib: array [ 1..10 ] of string ;
var tabpri: array [ 1..10 ] of string ;
var tabarr: array [ 1..10 ] of string ;
var tabnam: array [ 1..10 ] of string ;
var tabrefdent: array [ 1..10 ] of string ;
var tabsou: array [ 1..10 ] of string ;
var tabmai: array [ 1..10 ] of string ;
var tabcod: array [ 1..10 ] of string ;
var {choix,} art, i: integer;
LABEL choi,choi2,choi21,choi22,choi23,choi24,choi25,choi26,choi27,choi28;
begin

 tabnom[1] :='Bodenhorst';
 tabnom[2] :='Semal';
 tabnom[3] :='Swisser';
 tabnom[4] :='Michel';
 tabnom[5] :='       ';
 tabnom[6] :='       ';


 tabpre[1] :='Nicolas';
 tabpre[2] :='Elora';
 tabpre[3] :='Maureen';
 tabpre[4] :='Tim';
 tabpre[5] :='  ';

 tabrue[1] :='rue de Janville';
 tabrue[2] :='rue de la Maladrerie';
 tabrue[3] :='rue de saussois';
 tabrue[4] :='rue du Brasseur';
 tabrue[5] :='rue de Haute Pieree';
 tabrue[5] :='     ';

 tabnum[1] :='92';
 tabnum[2] :='81';
 tabnum[3] :='15';
 tabnum[4] :='22';
 tabnum[5] :='     ';

 tabcode[1] :='1350';
 tabcode[2] :='1370';
 tabcode[3] :='1367';
 tabcode[4] :='1357';
 tabcode[5] :='     ';

 tabloc[1] :='Jandrain';
 tabloc[2] :='Jodoigne';
 tabloc[3] :='Grand-rosiere';
 tabloc[4] :='Helecine';
 tabloc[5] :='     ';

 tabpay[1] :='Belgique';
 tabpay[2] :='Belgique';
 tabpay[3] :='Belgique';
 tabpay[4] :='Belgique';
 tabpay[5] :='     ';

 tabtel[1] :='015/55.66.05';
 tabtel[2] :='081/45.12.01';
 tabtel[3] :='010/94.73.54';
 tabtel[4] :='019/63.61.80';
 tabtel[5] :='     ';

 tabdat[1] :='20120710';
 tabdat[2] :='20120610';
 tabdat[3] :='20120410';
 tabdat[4] :='20120910';
 tabdat[5] :='     ';

 tabref[1] :='1';
 tabref[2] :='2';
 tabref[3] :='3';
 tabref[4] :='4';
 tabref[5] :='     ';

 tablib[1] :='Extraction simple';
 tablib[2] :='courone temporaire';
 tablib[3] :='Prothèse temporaire';
 tablib[4] :='Prothèse partielle';
 tablib[5] :='     ';

 tabpri[1] :='50 euros';
 tabpri[2] :='129 euros';
 tabpri[3] :='75 euros';
 tabpri[4] :='549 euros';
 tabpri[5] :='     ';

 tabarr[1] :='20120729';
 tabarr[2] :='20120822';
 tabarr[3] :='20121130';
 tabarr[4] :='20121003';
 tabarr[5] :='     ';

     
 tabrefdent[1] :='84184';
 tabrefdent[2] :='78157';
 tabrefdent[3] :='14872';
 tabrefdent[4] :='21549';
 tabrefdent[5] :='     ';


     choi:
     clrscr;
     gotoxy(25,2);writeln('--------------');
     gotoxy(25,3);writeln('Menu principal');
     gotoxy(25,4);writeln('--------------');
     gotoxy(10,6);writeln('1.Fichier client');
     gotoxy(10,7);writeln('2.Bon de commande commande');
     gotoxy(10,8);writeln('3.Quitter');
     gotoxy(35,8);readln(choix);
     if (choix = '1') then begin
        gotoxy(10,10);writeln('Vous avez choisi Fichier client');
        readln;
        goto choi21;
        end;
     if (choix = '2') then begin
           gotoxy(10,10);writeln('Vous avez choisi de creer un bon de commande');
           readln;
           goto choi22;
        end;
     if (choix ='3') then begin
        gotoxy(10,10);writeln('Le programme va fermer');
        readln();
        exit;
     end;
        choi2:
        clrscr;
        gotoxy(25,2);writeln('==============');
        gotoxy(25,3);writeln('Fichier client');
        gotoxy(25,4);writeln('==============');
        gotoxy(10,6);writeln('4.client');
        gotoxy(10,9);writeln('5.Menu principal');
        gotoxy(35,9);readln(choix);
        if (choix = '5') then begin
            goto choi;
            end;
        if (choix = '4') then begin
            goto23
            hoi23;
            end;
            choi23:
        clrscr;
        gotoxy(25,2);writeln('---------------');
        gotoxy(25,3);writeln('Fichier client');
        gotoxy(25,4);writeln('---------------');
        gotoxy(10,8);writeln('Nom du client : ');
        gotoxy(10,9);writeln('Prenom du client : ');
        gotoxy(10,15);readln(nom);
        gotoxy(35,9);readln(art);
        i:=1;
        while i < 10 do
   begin
   if nom = tabnom[i] then
   begin;
   clrscr;
    gotoxy(20,16);
    Writeln(' Affichage client ');
  gotoxy(10,5); Writeln('Nom client  : ',  tabnom[i] ) ;
  gotoxy(10,6); Writeln('Prenom client : ',  tabpre[i] ) ;
  gotoxy(10,7); Writeln('Rue client  : ',  tabrue[i] ) ;
  gotoxy(10,8); Writeln('Numero Domicile : ',  tabnum[i] ) ;
  gotoxy(10,9); Writeln('Code postal : ',  tabcode[i] ) ;
  gotoxy(10,10); Writeln('Localisation : ',  tabloc[i] ) ;
  gotoxy(10,11); Writeln('Pays : ',  tabpay[i] ) ;
  gotoxy(10,12); Writeln('telephone : ',  tabtel[i] ) ;
  gotoxy(10,13); Writeln('Date de commande : ',  tabdat[i] ) ;
  gotoxy(10,14); Writeln('Reference article : ',  tabref[i] ) ;
  gotoxy(10,15); Writeln('Libele article : ',  tablib[i] ) ;
  gotoxy(10,16); Writeln('Numero Domicile : ',  tabnum[i] ) ;

    readln();
 end;

      gotoxy(20,4);writeln('5.Menu principal');
        if (choix = '5') then begin
            goto choi;
        end;

         choi22:
        clrscr;
        gotoxy(25,2);writeln('----------------');
        gotoxy(25,3);writeln('Bon de commande');
        gotoxy(25,4);writeln('----------------');
        gotoxy(10,7);writeln('6.Creation du bon de commande');
        gotoxy(10,9);writeln('7.Menu principal');
        gotoxy(35,9);readln(choix);
        if (choix = '7') then begin
            goto choi;
            end;
        if (choix = '6') then begin
            goto choi24;
            end;
end;
end


Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: pls help in pascal programmation error
« Reply #1 on: August 29, 2012, 01:46:54 am »
First of all, it is not a lazarus project.
Try compiling it from a console: fpc filename.pas, or use the text mode fp ide to open the file and compile it.

Code: [Select]
if (choix = '4') then begin
            goto23

Obviously a typo:
Code: [Select]
if (choix = '4') then begin
            goto choi23

The very last end in the sourcefile misses a period ("."), it should be "end."

Finally there remain two labels that are used in a goto statement, but they do not appear as a label in the sourcecode (choi21 and choi24). If you know where the goto should go to, then at that place insert choi21: or choi24:  (note the colon at the end).

A final remark.
The extensive use of goto's and labels IMHO is an example of bad programming. It looks like classical BASIC spaghetti code.
You never need goto's in Pascal.
I would seriously recommend rewriting this.

Bart

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: pls help in pascal programmation error
« Reply #2 on: August 29, 2012, 10:02:35 am »
Quote
there is errors that i don't know how to solve.
And what are they? Please post the errors as well (if it's compile or runtime errors, but I guess it's compile time looking at invalid syntax everywhere). For compile time errors, try to read what the compiler said. Many starting programmers don't even read them and that makes simple problems complicated to solve.

 

TinyPortal © 2005-2018