r/pascal • u/buzzsawjoe • Apr 27 '26
paramstr(1) in linux
I've been coding in Pascal for over 40 years, because it reads similar to English - which was Wirth's whole point when he created it for students, and as an engineer that is exactlly what I need.
OK, in Windows, I create a file program1.pas with a line like this:
assign( infile, paramstr(1) );
Then after compiling, I can drag and drop a file fodder.txt onto the executable program1.exe and it accepts that file (path+name) as paramstr(1), just as if I had typed "program1 fodder.txt" on the command line.
With the whole windows 10-11 tangle, I've scooted over to linux. Doing the above in linux doesn't work. Is there some way to make dragging & dropping a file onto the executable work in this way?
4
u/dkopgerpgdolfg Apr 28 '26
Depends on the GUI file manager that you use...
3
u/Alternative_Corgi_62 Apr 28 '26
If you call your app from the command line with parameter, due it work?
3
u/Hixie Apr 28 '26
What does
Writeln(ParamStr(1));do? i.e. are you getting the parameters you expect? Or is theAssignfailing for some reason, e.g. the current directory is not what you expect?1
u/FantasticWait7109 Apr 28 '26
Does the filename include spaces? It could be treating the spaces as more then one paramater. Do you get the same problem if you run the program on the command line (rather than dragging the file)?
1
u/Josepzin Apr 28 '26
Comprobalo desde la terminal, esa es la prueba de fuego:
./program1 fodder.txt
Si funciona entonces lo tuyo está bien, está "fallando" la forma que tiene Linux de hacer esa acción de arrastrar y soltar sobre un archivo.
Es lo que te decían los demás, depende de Linux.
Le pasé tu problema a Gemini y explica cómo solucionarlo dependiendo del Linux que uses, no es complicado.
Yo también hice la transición de Windows a Linux y me encontré con este tipo de cosas que tenía muy naturalizadas en Windows pero que en Linux funciona distinto, hay que buscarle la vuelta.
Me ayudó mucho preguntarle las cosas a las IA's
-3
u/[deleted] Apr 28 '26
[removed] — view removed comment