SOLVED by Handoko // Help, some OLD code lazarus / 61-Beginners ---------------------------------------------------------------------- juanirias · 2018-09-17 14:50 Hi! Can some try to get working this codes? https://celestrak.com/software/vallado/pascal.zip Specially the testastf.pas & testpas.pas They are the companion of the Book Fundamentals of Astrodynamics and Applications by David Vallado. https://www.amazon.com/Fundamentals-Astrodynamics-Applications- Technology-Library/dp/1881883183/ref=sr_1_1?ie=UTF8&qid=1537198516&sr= 8-1&keywords=vallado Regards, JUAN ---------------------------------------------------------------------- wp · 2018-09-17 16:08 This is fairly old-fashioned Pascal code and should compile out of the box. It does not because of lots of syntax errors. Maybe it is some dialect which I don't know - but I fear this code was converted to Pascal from some other language by somebody who never tested what he wrote, it's a shame... Do you know that astronomical calculations are available for Lazarus via the Online Package Manager in the packages DelphiMoon and SysTools? ---------------------------------------------------------------------- juanirias · 2018-09-17 17:19 Hi wp ! Thanks for answer. Attached the files below... I can get working until example 3-7, but have some troubles with the function CONVTIME specific on the first parameter. ( ConvTime is part os AstTime.pas). Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i PROCEDURE CONVTIME           ( FileN1                                : Str64;                             Year,Mon,Day,Hr,MIN                   : INTEGER;                               SEC                                 : EXTENDED;                               TimeZone                            : INTEGER;                               TypeUTIn                            : CHAR;                               VAR DUT1,DAT,xp,yp,UT1,TUT1,JDUT1,UTC,JDUTC,                               TAI,TT,TTT,JDTT,TDB,TTDB,JDTDB,DDPsi,DDEps,XLOD : EXTENDED;                             VAR Error                             : Str12   );   I will review DelphiMoon and SysTools! ( can share a link of the source code, because I'm under Linux...) Can try to compile the example_3_7.pas ? I have this error: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i An unhandled exception occurred at $0000000000425F14:EInOutError: File not found  $0000000000425F14  $000000000040177E ---------------------------------------------------------------------- BlueIcaro · 2018-09-17 18:09 Hi, I'm not a expert, but your error seems to be a runtime error. And said something about a missing file. I other waey, you can get more info, and download online package manager from here: http://wiki.freepascal.org/Online_Package_Manager /BlueIcaro ---------------------------------------------------------------------- juanirias · 2018-09-17 18:18 Hi! I'm have a dude at: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         ReadLn( InFile, FileN1 );   regards, JUAN ---------------------------------------------------------------------- BlueIcaro · 2018-09-17 18:34 Quote from: juanirias on September 17, 2018, 08:18:38 pmHi! I'm have a dude at: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         ReadLn( InFile, FileN1 );   regards, JUAN Veo que firmas con un nombre español, en este foro hay una sección en español, quizás allí te sea más fácil exponer tus dudas. /BlueIcaro ---------------------------------------------------------------------- skalogryz · 2018-09-17 18:34 Seems like the code needs to be compiled using Turbo Pascal syntax Code: [Select]        PROCEDURE TestDAYOFWEEK;       VAR          JD : Extended;          DayW, DAYOFWEEK : INTEGER; // DAYOFWEEK should not be declared here,                                     //  as it's a function in a another unit       BEGIN         ReadLn( InFile, JD );         WriteLn( OutFile,  JD );         DayW := DAYOFWEEK  ( JD );         WriteLn( OutFile, '  Results:' );         WriteLn( OutFile, DayW );       END; compiles fine as: Code: [Select]        PROCEDURE TestDAYOFWEEK;       VAR          JD : Extended;          DayW: INTEGER;       BEGIN         ReadLn( InFile, JD );         WriteLn( OutFile,  JD );         DayW := DAYOFWEEK  ( JD );         WriteLn( OutFile, '  Results:' );         WriteLn( OutFile, DayW );       END; Was that code SCANNED out of the book? ---------------------------------------------------------------------- juanirias · 2018-09-17 23:22 Thanks for letting me know! The idea of ask for help here in English is because I'm thinking is more people on English vocabulary than Spanish... I'm trying to make work the examples of the book from the scratch... Regards, Juan ---------------------------------------------------------------------- juanirias · 2018-09-18 19:56 Hi! I'm under linux, Can figure IF is a permission issue of the OS? Can try someone to compile under Windows ? regards, JUAN ---------------------------------------------------------------------- juanirias · 2018-09-18 21:47 Today I'm here: Runtime error 103 The error is next to         ReadLn( InFile, FileN1 );  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program example_3_7;       (* p.195 *)         uses asttime,astmath;  var                         Year,Mon,Day,Hr,MIN                   : INTEGER;      SEC                                   : EXTENDED;      TimeZone                              : INTEGER;      TypeUTIn                            : CHAR;      DUT1,DAT,xp,yp,UT1,TUT1,JDUT1,UTC,JDUTC,TDT,TTDT,JDTDT,      TAI,TT,TTT,JDTT,TDB,TTDB,JDTDB,DDPsi,DDEps,XLOD : EXTENDED;      Error                                     : Str12   ;      FileN1,IFileName                              : Str64;           InFile,OutFile : TEXTfile;                                 begin                       IFileName := 'text.in';        ASSIGN( InFile,IFileName );        RESET( InFile );         ASSIGN( OutFile,'text.out');        Rewrite( OutFile );                     ReadLn( InFile, Year,Mon,Day,Hr,Min,Sec,TimeZone,TypeUtIn );        writeln('pudo leer el archivo!');        writeln('year ',year:4);        writeln('mon  ',mon:2);        writeln('day  ',day:2);        writeln(hr:2,' : ',min:2,' : ',sec:2:2);                Write( OutFile, 'In',Year,Mon,Day,Hr,Min,Sec,TimeZone,TypeUtIn );         ReadLn( InFile, FileN1 );                                   CONVTIME( FileN1,Year,Mon,Day,Hr,MIN,SEC,TimeZone,TypeUTIn , DUT1,DAT,xp,yp,UT1, TUT1,JDUT1,UTC,JDUTC,TAI,TT,TTT,JDTT,TDB,TTDB,JDTDB,DDPsi,DDEps,XLOD,E rror);                            WriteLn( OutFile, '  Results:' );      WriteLn( OutFile, DUT1,' ',DAT,' ',xp,' ',yp,' ' );        WriteLn( OutFile, UT1,' ',TUT1,' ',JDUT1,' ',UTC,' ',TAI,' ',tdt );      WriteLn( OutFile, TTDT,' ',JDTDT,' ',TDB,' ',TTDB,' ',JDTDB );                                                      end. ---------------------------------------------------------------------- Bart · 2018-09-18 21:50 Yeah, nice meaningfull variable names  Bart ---------------------------------------------------------------------- juanirias · 2018-09-19 16:16 Hi Bart! The mistake is on Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         Readln( InFile, FileN1 ); I cannot understand well... regards, JUAN ---------------------------------------------------------------------- Handoko · 2018-09-19 16:29 I tested the code you provided but removing the CONVTIME and the uses clauses. No problem here on my Linux, everything seemed to work correctly. I think the problem should be in the text file not the code. About the comment by Bart, he just telling you the good practice in coding. Using good names for variables, procedures and functions is very helpful, it will make the code more maintainable and easier to debug. Maybe you haven't know, one of the notable difference about experienced programmers and novice programmers. Experienced programmers won't use meaningless name for variables. For examples:  DUT1, DAT, xp, yp, UT1, TUT1, JDUT1, UTC, JDUTC, TDT, TTDT, JDTDT, TAI, TT, TTT, JDTT, TDB, TTDB, JDTDB, DDPsi, DDEps, XLOD. If you have chances, I recommend you to read this book. It explains the things a master/experienced programmer usually do, including why we should choose good/meaningful names: https://en.wikipedia.org/wiki/Code_Complete ---------------------------------------------------------------------- juanirias · 2018-09-19 16:36 Thanks for the advice Handoko; You are right; I'm not a pro... I will try to read the link; I appreciate the message. The error is next to Readln( InFile, FileN1 ) Can figure or give some clue to fix-it ? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   ////                     Individual PROCEDURES////  These subroutines implement each function or procedure using a datafile//    with the number of each routine to identify which subroutine to use.////  ----- -------------------------------------------------------------------    PROCEDURE TestConvTime;      VAR        Year, Mon, Day, Hr, MIN, TimeZone: INTEGER;        TypeUTIn:char;        FileN1:str64;        Error:str12;        DUT1,DAT,xp,yp,UT1,TUT1,JDUT1,UTC,JDUTC,TAI,TT,TTT ,JDTT,TDB,TTDB,JDTDB,DDPsi,DDEps,XLOD,sec : Extended;       BEGIN      writeln('adentro del  procedimiento');                                   Read( InFile, Year,Mon,Day,Hr,Min,Sec,TimeZone,TypeUtIn );      Write( 'OutFile', ' year ',Year,' month ',Mon,' day ',Day,'  ',Hr,':',Min,':',Sec:2:2,' zone: ',TimeZone,'  ',TypeUtIn,  ' fin ' );        writeln('***');       //CONVTIME(FileN1,Year,Mon,Day,Hr,MIN,SEC,TimeZone,TypeUTIn,DUT1,DAT, xp, yp, UT1,TUT1, JDUT1, UTC, TAI, TDT, TTDT, JDTDT,TDB,TTDB, JDTDB, Error );        Readln( InFile, FileN1 );        CONVTIME(FileN1, Year,Mon,Day,Hr,MIN,SEC,TimeZone,TypeUTIn,  DUT1,DAT,xp,yp,UT1,TUT1,JD UT1,UTC,JDUTC,TAI,TT,TTT,JDTT,TDB,TTDB,JDTDB,DDPsi,DDEps,XLOD,Error);        WriteLn( OutFile, '  Results:' );        WriteLn( OutFile, DUT1,' ',DAT,' ',xp,' ',yp,' ' );        WriteLn( OutFile, UT1,' ',TUT1,' ',JDUT1,' ',UTC,' ',TAI,' ',tt );        WriteLn( OutFile, ttt,' ',JDTT,' ',TDB,' ',TTDB,' ',JDTDB,' ',JDTDB,' ',DDPsi,' ',DDEps,' ',XLOD,' ',Error );                        END;  BEGIN // --------------------------- M A I N -----------------------------        IFileName := 'in.dat';        ASSIGN( InFile,IFileName );        RESET( InFile );                {$I-}                { open it      }   {$I+}   if IOresult<>0 then   begin     writeln('Error encountered in reading file ');     halt;   end;         ASSIGN( OutFile,'dat.out' );        Rewrite( OutFile );{$I-}                { open it      }   {$I+}   if IOresult<>0 then   begin     writeln('Error encountered in write file ');     halt;   end;                writeln('previo al llamado del procedimiento');        TestConvTime;                         CLOSE( InFile );        CLOSE( OutFile );     END. // Program Testastf ---------------------------------------------------------------------- Handoko · 2018-09-19 16:40 As I told you previously, I cannot reproduce the issue. Can you provide all the necessary files, including the in.dat, out.dat, text.in, text.out? I need to inspect them to understand the problem. ---------------------------------------------------------------------- juanirias · 2018-09-19 16:43 Thanks in advance! Attached in ZIP regards, JUAN ---------------------------------------------------------------------- Handoko · 2018-09-19 16:53 Still cannot compile the program. It needs AstUtil.pas. ---------------------------------------------------------------------- juanirias · 2018-09-19 16:54 Sorry... ---------------------------------------------------------------------- Handoko · 2018-09-19 17:20 I got Runtime Error(2) on the Reset below: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i      ASSIGN( TimeFile,FileN1 );     RESET( TimeFile); It happened because you forget to put this before the Assign command: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i      FileN1 := 'in.dat'; And I got Runtime Error(103) on the Writeln below: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i          WriteLn( FileOut,Error,JD:18:12,' too far' ); It happened because you forget to call Assign, give it a proper filename and call Rewrite: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i      Assign(FileOut, 'out.dat');     Rewrite(FileOut); ---------------------------------------------------------------------- juanirias · 2018-09-19 17:32 Thanks! You are good!