MSDOS Arguments lazarus / 68-Other OS ---------------------------------------------------------------------- Coldfire · 2017-06-02 08:00 Hi, i'm trying to port a very short programfrom linux to MSDOS-8086. 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 project1;Uses sysutils;var  arginput       :        string;  argoutput      :        string;  fileinput      :        file;  fileoutput     :        text;  dumpbuf        :        word;  resultado      :        integer;  begin     arginput:=ParamStr(1);     argoutput:=ParamStr(2);     assign(fileinput,arginput);     assign(fileoutput,argoutput);     reset(fileinput,2);     rewrite(fileoutput);     write(fileoutput,' dw ');   blockread(fileinput, dumpbuf, 2, resultado);     write(fileoutput, '0', format('%x',[dumpbuf]),'h');     while(eof(fileinput)=false) do     begin         blockread(fileinput, dumpbuf, 2, resultado);         write(fileoutput, ', 0', format('%x',[dumpbuf]),'h');       end;     close(fileinput);     close(fileoutput);     writeln(resultado);end.in linux works somewhat great(dumps a file into little endian words written in a text file), but it behaves strange in MSDOS. Apparently is ignoring arguments. Also it expects a CRLF from keyboard to finish. MSDOS arguments have limitations? Thanks ---------------------------------------------------------------------- marcov · 2017-06-02 08:01 The eof() is for cooked I/O not blockread. EOF with blockread is when resultado<> the number of bytes read (mostly 2 in your case) So the Linux program is wrong, and might only happen to work by chance ---------------------------------------------------------------------- Ñuño_Martínez · 2017-06-02 10:54 Also note that Linux will expand filename wildcards (i.e. "file*", "file??" ...). Neither MS-DOS or Windows does it.  I don't know about others. ---------------------------------------------------------------------- Coldfire · 2017-06-02 15:14 Quote from: marcov on June 02, 2017, 10:01:35 amThe eof() is for cooked I/O not blockread. EOF with blockread is when resultado<> the number of bytes read (mostly 2 in your case) So the Linux program is wrong, and might only happen to work by chance good point. Now that is fixed, linux version works ok, but DOS version is still printing the file to stdout instead of specified file, and still waits for a CRLF from keyboard... ---------------------------------------------------------------------- marcov · 2017-06-02 15:25 Start with using reset(f,1); ---------------------------------------------------------------------- Coldfire · 2017-06-02 16:18 using reset(f,2) and hardcoding file name, it works. However 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 write(fileoutput,' dw '); fileoutput is null  . i print it manually 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 arginput:=ParamStr(1);     argoutput:=ParamStr(2);     writeln(arginput); but does not print nothing (well, prints a CRLF from writeln) ---------------------------------------------------------------------- marcov · 2017-06-02 16:39 Call paramstr() for numbers higher than paramcount is illegal. ---------------------------------------------------------------------- Bart · 2017-06-02 16:46 Quote from: marcov on June 02, 2017, 06:39:47 pmCall paramstr() for numbers higher than paramcount is illegal. Huh? ParamStr(ParamCount+n), where n>0, simply has to return an empty string (see: http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.ParamStr). It's not illegal, it's maybe a little foolish though. Bart ---------------------------------------------------------------------- marcov · 2017-06-02 16:49 Quote from: Bart on June 02, 2017, 06:46:51 pmQuote from: marcov on June 02, 2017, 06:39:47 pmCall paramstr() for numbers higher than paramcount is illegal. Huh? ParamStr(ParamCount+n), where n>0, simply has to return an empty string (see: http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.ParamStr). It's not illegal, it's maybe a little foolish though. Bart Params* are overriden in objpas, so the Object Pascal case might be different from the fpc case. Though that is not why I was wrong, it is just defensive programming from the early days I guess. ---------------------------------------------------------------------- Coldfire · 2017-06-02 16:50 writeln(paramcount); writes 1 when i put in console ">:/project1 a" but writeln(paramstr(1)); just prints a CRLF now code goes in this 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 project1;Uses sysutils, dos;var  arginput       :        string;  argoutput      :        string;  fileinput      :        file;  fileoutput     :        text;  dumpbuf        :        word;  resultado      :        integer;  begin     writeln(paramcount);     //arginput:=ParamStr(1);     //argoutput:=ParamStr(2);     writeln(paramstr(1));     assign(fileinput,'input.ans');     assign(fileoutput,'output.ans');     reset(fileinput,2);     reset(fileoutput);     rewrite(fileoutput);     write(fileoutput,' dw ');     blockread(fileinput, dumpbuf, 1, resultado);     write(fileoutput, '0', format('%x',[dumpbuf]),'h');     while(resultado=1) do       begin       blockread(fileinput, dumpbuf, 1, resultado);         write(fileoutput, ', 0', format('%x',[dumpbuf]),'h');       end;     close(fileinput);     close(fileoutput);     //writeln(resultado); ---------------------------------------------------------------------- Coldfire · 2017-06-02 17:04 OK, i fixed it. I changed mode Objfpc to mode Freepascal and now outputs the correct parameters. Now is this a bug or a feature? because, in project options I stated Without ansistrigs, however, in mode objfpc when i search ParamStr declaration I find 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 {$ifdef FPC_HAS_FEATURE_COMMANDARGS}     { ParamStr should return also an ansistring }     Function ParamStr(Param : Integer) : Ansistring;{$endif FPC_HAS_FEATURE_COMMANDARGS} So error probably comes from this part. I was trying to assign an ansistring to a pascal string an then triying to pass it to a pascal string argument. Also randomly appears the following error system.pp(57,47) Error: se esperaba ;, pero se encontro : in that line system.pp says mem  : array[0..$7fff-1] of byte absolute $0:$0;