Results 1 to 3 of 3

Thread: Help with program

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    1

    Help with program

    Howdy
    Alright could really use help on getting this program working correctly.
    What I want it to do is to read my text file,
    Smith, John
    532
    589
    Jones, Dan
    421
    610

    and then I want it to rearrange the names and scores and write to the outfile
    Name_____________Math Score_________English Score________Total Score
    Dan Jones _________421_______________610__________________1041
    John Smith _________532_______________589__________________1121

    I just can't seem to get any of this right, if anyone could help I would greatly appreciate it
    Code:
    program SatScores;
    
    uses
      Forms;
    
    { }
    Const
    	 DATA_NUMB = 2;
    type
     	  info=record
    	  name,fName,lName:string;
              newName:string;
     	  end;
    studArray=array[1..DATA_NUMB]of info;
    var
       data:studArray;
       outFile,inFile:textFile;
       number:integer;
       N:string;
    
    
    Procedure Start;
    begin
      Assignfile(outfile,'Info.out');
      rewrite(outfile);
      Assignfile(infile,'Data.txt');
      reset(infile);
    
                write('What is your name?: ');
                readln(N);
                writeln(outfile,'This program was run by: ',N);
                writeln(outfile);
                end;
    
    
    
    Procedure GetInfo;
    var
    loop:integer;
    begin
        for loop:=1 to DATA_NUMB do
          begin
           readln(infile,data[loop].name);
          end;
    
    end;
    
    Procedure Calculate;
    begin
    readln(infile,number);
    writeln(outfile,number);
    writeln(outfile,'----------------------------------------');
     end;
    Procedure Date;
    Var
    blnkSpace,ndspace,comma:integer;
    loop:integer;
    name,fName,lName:string;
     newDate,newName:string;
    begin
    
    blnkspace:=pos(' ',data[loop].name);
    comma:=pos(',',data[loop].name);
    
    
    fName:=copy(data[loop].name,succ(blnkspace),length(data[loop].name)-blnkspace);
    lName:=copy(data[loop].name,1,pred(blnkspace));
    newName:=Concat(fName,lName);
    writeln(outfile,'----------------------------------------');
    writeln(outfile,'Old name:',data[loop].name);
    writeln(outfile,'New name:',newName);
    
    
    end;
    Procedure Finish;
    begin
    
    writeln(outfile);
    writeln(outfile,'This program was created by ');
    closefile(outfile);
    closefile(infile);
    
    
    end;
    begin
    Start;
    GetInfo;
    Calculate;
    
    Finish;
    end.
    This is the text file
    Code:
    Smith, John	
    532
    589
    Jones, Dan
    421
    610
    Dover, Ilene
    338
    499
    Adams, Paige
    670
    200
    Last edited by la65cop; Mar 24th, 2009 at 09:39 PM.

  2. #2
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: Help with program

    Perhaps posting what language this is might help?
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  3. #3
    New Member
    Join Date
    Apr 2009
    Posts
    1

    Re: Help with program

    That's a Pascal command line program. It was posted over a month ago so I won't debug it, but there are easier ways of doing that in Delphi or FreePascal with Lazarus. Well, unless it's a classroom project or something that requires using the old school ways...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width