ok, when i try and compile my unfinished program at the bottom:
it gives me these two errors

c:\documents and settings\owner\desktop\programming stuff\programming practice (pascal)\unitconverter.pas:6: warning: missing string capacity - assuming 255
c:\documents and settings\owner\desktop\programming stuff\programming practice (pascal)\unitconverter.pas:7: parse error before `In'

and i'm new to programming so i dont know what they mean. please help

program unitconverter;

uses crt;
label 1;
var
   unit : string;
   in,inft : real;
begin

     textbackground(black);
     1:clrscr;
     textcolor(white);
     gotoxy(2,2);
     writeln('1. Inches (in)');
     gotoxy(2,3);
     writeln('2. Feet (ft)');
     gotoxy(2,4);
     writeln('3. Yards (yd)');
     gotoxy(2,5);
     writeln('4. Miles (mi)');
     gotoxy(2,6);
     writeln('5. Milimeters (mm)');
     gotoxy(2,7);
     writeln('6. Cenimeters (cm)');
     gotoxy(2,8);
     writeln('7. Meters (m)');
     gotoxy(2,9);
     writeln('8. Kilometers (km)');
     gotoxy(2,11);
     write('Choose a unit to convert from by entering its abbreviation:');
     readln(unit);
     clrscr;
     if unit='in' then
        begin
        gotoxy(2,2);
        write('Enter number of ',unit,' to convert:');
        readln(in);
        clrscr;
        gotoxy(2,2);
        writeln(,in ,, unit,'=');
        inft:= in / 12;
        gotoxy(2,4);
        writeln(,inft,' Foot\Feet');
        readln;
        end.
end.

Recommended Answers

All 6 Replies

What version of TP are you using? My TP4 wouldn't get past the 8+ letter filename.

First, you are forbidden to use reserved words as identifiers. That means unit and in are off-limits.

You must then go through and fix all the syntax errors. (Watch the ',' in your write statements, and only the last end should be followed by a '.'.)

Lastly, if you are planning to do what I think you are with that label, don't. Use a loop.

program unitconv;
uses Crt;

procedure do_a_conversion;
  var
    unit_name: string;
    inches, inches_in_feet: real;
    ...
  begin
  ...
  end;

begin
  writeln( 'Lytre''s unit converter' );
  writeln;
  repeat
    do_a_conversion;
    write( 'Would you like to do another (Y/N)? ' )
  until upcase( readkey ) <> 'Y'
end.

Hope this helps.

Thanks alot now it compiles and converts inches to feet and i was just going to try out the label because I'm still learning pascal and the tutorial I'm leaning it from didn't explain what it does exactly . and what's a TP

What version of TP are you using? My TP4 wouldn't get past the 8+ letter filename.

First, you are forbidden to use reserved words as identifiers. That means unit and in are off-limits.

You must then go through and fix all the syntax errors. (Watch the ',' in your write statements, and only the last end should be followed by a '.'.)

Lastly, if you are planning to do what I think you are with that label, don't. Use a loop.

program unitconv;
uses Crt;

procedure do_a_conversion;
  var
    unit_name: string;
    inches, inches_in_feet: real;
    ...
  begin
  ...
  end;

begin
  writeln( 'Lytre''s unit converter' );
  writeln;
  repeat
    do_a_conversion;
    write( 'Would you like to do another (Y/N)? ' )
  until upcase( readkey ) <> 'Y'
end.

Hope this helps.

TP = Turbo Pascal Software

Oh, ok I'm not using turbo pascal I'm using dev-pascal.

TP = Turbo Pascal Software

Ok, I finished the code for my first useful program and all i have to do is check to see if all the conversions are right. Here's the source code for it:

program unit_converter;
uses crt;
var
   unit_ : string;
   yn : char;
   in_,in_a,
   ft_,ft_a,
   yd_,yd_a,
   mi_,mi_a,
   mm_,mm_a,
   cm_,cm_a,
   m_,m_a,
   km_,km_a : real;
begin
repeat
     textbackground(black);
     clrscr;
     textcolor(white);
     gotoxy(33,2);
     writeln('Unit Converter ');
     gotoxy(2,4);
     writeln('1. Inches (in)');
     gotoxy(2,5);
     writeln('2. Feet (ft)');
     gotoxy(2,6);
     writeln('3. Yards (yd)');
     gotoxy(2,7);
     writeln('4. Miles (mi)');
     gotoxy(2,8);
     writeln('5. Milimeters (mm)');
     gotoxy(2,9);
     writeln('6. Cenimeters (cm)');
     gotoxy(2,10);
     writeln('7. Meters (m)');
     gotoxy(2,11);
     writeln('8. Kilometers (km)');
     gotoxy(2,12);
     writeln('9. Or enter (ex) to exit the program');
     gotoxy(2,15);
     write('Choose a unit to convert from by entering its abbreviation:');
     readln(unit_);
     clrscr;
     if unit_='in' then
        begin
        unit_:= 'inches';
        gotoxy(2,2);
        write('Enter number of ',unit_,' to convert:');
        readln(in_);
        clrscr;
        gotoxy(2,2);
        writeln(in_:1:3 ,unit_,'=');
        in_a:= in_/12;
        gotoxy(2,6);
        writeln(in_a:1:3,' Feet');
        in_a:= in_/36;
        gotoxy(2,8);
        writeln(in_a:1:3,' Yards');
        in_a:= in_/63360;
        gotoxy(2,10);
        writeln(in_a:1:3,' Miles');
        in_a:= in_*(254/10);
        gotoxy(2,12);
        writeln(in_a:1:3,' Millimeters');
        in_a:= in_*(254/100);
        gotoxy(2,14);
        writeln(in_a:1:3,' Centimeters');
        in_a:= in_*(254/10000);
        gotoxy(2,16);
        writeln(in_a:1:3,' Meters');
        in_a:= in_*(254/10000000);
        gotoxy(2,18);
        writeln(in_a:1:3,' Kilometers');
        delay(1500); gotoxy(2,22);
        writeln('Press enter to continue...');
        readln;
        end;
        if unit_='ft' then
        begin
        unit_:= 'feet';
        gotoxy(2,2);
        write('Enter number of ',unit_,' to convert:');
        readln(ft_);
        clrscr;
        gotoxy(2,2);
        writeln(ft_:1:2 ,unit_,'=');
        ft_a:= ft_*12;
        gotoxy(2,6);
        writeln(ft_a:1:3,' Inches');
        ft_a:=ft_/3;
        gotoxy(2,8);
        writeln(ft_a:1:3,' Yards');
        ft_a:= ft_/5280;
        gotoxy(2,10);
        writeln(ft_a:1:3,' Miles');
        ft_a:= ft_*(3048/10);
        gotoxy(2,12);
        writeln(ft_a:1:3,' Millimeters');
        ft_a:= ft_*(3048/100);
        gotoxy(2,14);
        writeln(ft_a:1:3,' Centimeters');
        ft_a:= ft_*(3048/10000);
        gotoxy(2,16);
        writeln(ft_a:1:3,' Meters');
        ft_a:= ft_*(3048/10000000);
        gotoxy(2,18);
        writeln(ft_a:1:3,' Kilometers');
        delay(1500); gotoxy(2,22);
        writeln('Press enter to continue...');
        readln;
        end;
        if unit_='yd' then
        begin
        unit_:= 'Yards';
        gotoxy(2,2);
        write('Enter number of ',unit_,' to convert:');
        readln(yd_);
        clrscr;
        gotoxy(2,2);
        writeln(yd_:1:2 ,unit_,'=');
        yd_a:= yd_*36;
        gotoxy(2,6);
        writeln(yd_a:1:3,' Inches');
        yd_a:= yd_*3;
        gotoxy(2,8);
        writeln(yd_a:1:3,' Feet');
        yd_a:= yd_/1760;
        gotoxy(2,10);
        writeln(yd_a:1:3,' Miles');
        yd_a:= yd_*(9144/10);
        gotoxy(2,12);
        writeln(yd_a:1:3,' Millimeters');
        yd_a:= yd_*(9144/100);
        gotoxy(2,14);
        writeln(yd_a:1:3,' Centimeters');
        yd_a:= yd_*(9144/10000);
        gotoxy(2,16);
        writeln(yd_a:1:3,' Meters');
        yd_a:= yd_*(9144/10000000);
        gotoxy(2,18);
        writeln(yd_a:1:3,' Kilometers');
        delay(1500); gotoxy(2,22);
        writeln('Press enter to continue...');
        readln;
        end;
        if unit_='mi' then
        begin
        unit_:= 'miles';
        gotoxy(2,2);
        write('Enter number of ',unit_,' to convert:');
        readln(mi_);
        clrscr;
        gotoxy(2,2);
        writeln(mi_:1:3 ,unit_,'=');
        mi_a:= mi_*63360;
        gotoxy(2,6);
        writeln(mi_a:1:3,' Inches');
        mi_a:= mi_*5280;
        gotoxy(2,8);
        writeln(mi_a:1:3,' Feet');
        mi_a:= mi_*1760;
        gotoxy(2,10);
        writeln(mi_a:1:3,' Yards');
        mi_a:= mi_*1609344;
        gotoxy(2,12);
        writeln(mi_a:1:3,' Millimeters');
        mi_a:= mi_*(1609344/10);
        gotoxy(2,14);
        writeln(mi_a:1:3,' Centimeters');
        mi_a:= mi_*(1609344/1000);
        gotoxy(2,16);
        writeln(mi_a:1:3,' Meters');
        mi_a:= mi_*(1609344/1000000);
        gotoxy(2,18);
        writeln(mi_a:1:3,' Kilometers');
        delay(1500); gotoxy(2,22);
        writeln('Press enter to continue...');
        readln;
        end;
        if unit_='mm' then
        begin
        unit_:= 'millimeters';
        gotoxy(2,2);
        write('Enter number of ',unit_,' to convert:');
        readln(mm_);
        clrscr;
        gotoxy(2,2);
        writeln(mm_:1:3 , unit_,'=');
        mm_a:= mm_*(394/10000);
        gotoxy(2,6);
        writeln(mm_a:1:3,' Inches');
        mm_a:= mm_*(328/1000);
        gotoxy(2,8);
        writeln(mm_a:1:3,' Feet');
        mm_a:= mm_*(109/100000);
        gotoxy(2,10);
        writeln(mm_a:1:3,' Yards');
        mm_a:= mm_*(6214/1000);
        gotoxy(2,12);
        writeln(mm_a:1:3,' Miles');
        mm_a:= mm_/10;
        gotoxy(2,14);
        writeln(mm_a:1:3,' Centimeters');
        mm_a:= mm_/1000;
        gotoxy(2,16);
        writeln(mm_a:1:3,' Meters');
        mm_a:= mm_/1000000;
        gotoxy(2,18);
        writeln(mm_a:1:3,' Kilometers');
        delay(1500); gotoxy(2,22);
        writeln('Press enter to continue...');
        readln;
        end;
        if unit_='cm' then
        begin
        unit_:= 'centimeters';
        gotoxy(2,2);
        write('Enter number of ',unit_,' to convert:');
        readln(cm_);
        clrscr;
        gotoxy(2,2);
        writeln(cm_:1:3, unit_,'=');
        cm_a:= cm_*(254*100);
        gotoxy(2,6);
        writeln(cm_a:1:3,' Inches');
        cm_a:= cm_*(328/10000);
        gotoxy(2,8);
        writeln(cm_a:1:3,' Feet');
        cm_a:= cm_*(109/10000);
        gotoxy(2,10);
        writeln(cm_a:1:3,' Yards');
        cm_a:= cm_*(6213/1000);
        gotoxy(2,12);
        writeln(cm_a:1:3,' Miles');
        cm_a:= cm_*10;
        gotoxy(2,14);
        writeln(cm_a:1:3,' Millimeters');
        cm_a:= cm_/100;
        gotoxy(2,16);
        writeln(cm_a:1:3,' Meters');
        cm_a:= cm_/100000;
        gotoxy(2,18);
        writeln(cm_a:1:3,' Kilometers');
        delay(1500); Gotoxy(2,22);
        writeln('Press enter to continue');
        readln;
        end;
        if unit_='m' then
        begin
        unit_:='millimeters';
        gotoxy(2,2);
        write('Enter number of ',unit_,' to convert:');
        readln(m_);
        clrscr;
        gotoxy(2,2);
        writeln(m_:1:3, unit_,'=');
        m_a:= m_*(3937/100);
        gotoxy(2,6);
        writeln(m_a:1:3,' Inches');
        m_a:= m_*(328/100);
        gotoxy(2,8);
        writeln(m_a:1:3,' Feet');
        m_a:= m_*(1094/1000);
        gotoxy(2,10);
        writeln(m_a:1:3,' Yards');
        m_a:= m_*(6214/1000);
        gotoxy(2,12);
        writeln(m_a:1:3,' Miles');
        m_a:= m_/1000;
        gotoxy(2,14);
        writeln(m_a:1:3,' Milllimeters');
        m_a:= m_/100;
        gotoxy(2,16);
        writeln(m_a:1:3,' Centimeters');
        m_a:= m_*1000;
        gotoxy(2,18);
        writeln(m_a:1:3,' Kilometers');
        delay(1500); gotoxy(2,22);
        writeln('Press enter to continue...');
        readln;
        end;
        if unit_='km' then
        begin
        unit_:='kilometers';
        gotoxy(2,2);
        write('Enter number of ',unit_,' to convert:');
        readln(km_);
        clrscr;
        gotoxy(2,2);
        writeln(km_:1:3, unit_,'=');
        km_a:= km_*(39370079/1000);
        gotoxy(2,6);
        writeln(km_a:1:3,' Inches');
        km_a:= km_*(3280839/1000);
        gotoxy(2,8);
        writeln(km_a:1:3,' Feet');
        km_a:= km_*(1093613/1000);
        gotoxy(2,10);
        writeln(km_a:1:3,' Yards');
        km_a:= km_*(6124/1000);
        gotoxy(2,12);
        writeln(km_a:1:3,' Miles');
        km_a:= km_*1000000;
        gotoxy(2,14);
        writeln(km_a:1:3,' Milllimeters');
        km_a:= km_*100000;
        gotoxy(2,16);
        writeln(km_a:1:3,' Centimeters');
        km_a:= km_*1000;
        gotoxy(2,18);
        writeln(km_a:1:3,' Meters');
        delay(1500); gotoxy(2,22);
        writeln('Press enter to continue...');
        readln;
        end;
        if unit_='ex' then halt;
        clrscr;
        gotoxy(2,2);
        write('Exit (Y/N):');
        readln(yn);
        until (yn='y');
        halt;
end.

Bro.Nice.If u dont mind i took the source and test it.i have to say nice job.cya around

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.