Recent

Author Topic: FreePascal doesn't run my programs (any)  (Read 3437 times)

fxeconomist

  • New Member
  • *
  • Posts: 48
FreePascal doesn't run my programs (any)
« on: August 19, 2024, 02:04:53 am »
I'm returning to this problem, because somehow it still puzzles me.

I have two Windows 11 partitions. On one of them, FP works perfectly. On the other, FP doesn't run my programs. Any program. I reinstalled it and Lazarus, but the error was still there.

It does compile, and then at run it tells me "The program ... does not run. DosError = 13". I didn't find any description for DosError 13.

However, the program exists there and can be run from cmd.

I also found that it can't run the shell.

But here's the kicker. I found a strange fix. I adapted the FP shortcut. I made a cmd file that launches FP, and have the shortcut cmd run that file.

Only this way, it can run programs, and can run the shell. Only if FP runs from CMD, but not if FP runs directly from Windows.

The thing is, I don't wanna wipe that Windows just because FP has a tiny snag.

dbannon

  • Hero Member
  • *****
  • Posts: 3156
    • tomboy-ng, a rewrite of the classic Tomboy
Re: FreePascal doesn't run my programs (any)
« Reply #1 on: August 19, 2024, 02:49:57 am »
A picky point, no solution (you are very unlikely to get a windows solution from me !).

May be its a terminology issue but I am struggling to make sense of your report. Firstly, lets get this clear. You start with some source code, FPC complies that into an executable (Lazarus asks FPC to do it) and then Lazarus runs your program for you.

So, by my reckoning, your fix of a cmd file instead of fpc would make no difference when running the program (fpc is not, then, involved) but would possibly make a difference when compiling.

Now, if what you appear to be saying is literally true, your fix is somehow building a different binary at compile time, one that will run on your system.  Thats an important clue to what is happening.

I hope you don't think I am being awkward here, its just that what you seem to be describing is unlikely but, never the less, possible.

Could you clarify please ?

Maybe compile (ie "build", or even "clean up and rebuild") in both modes, with and without your fix, and see if the two binaries are different ?

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Aruna

  • Hero Member
  • *****
  • Posts: 513
Re: FreePascal doesn't run my programs (any)
« Reply #2 on: August 19, 2024, 03:04:45 am »
It does compile, and then at run it tells me "The program ... does not run. DosError = 13". I didn't find any description for DosError 13.

DOS Error LIst

Error Code 13: Invalid data
Description     : The data provided is invalid or not in the expected format.

jamie

  • Hero Member
  • *****
  • Posts: 6735
Re: FreePascal doesn't run my programs (any)
« Reply #3 on: August 19, 2024, 03:11:59 am »
https://courses.cs.umbc.edu/undergraduate/CMSC211/spring02/burt/lectures/Chap18/DOSerrors.html

Open mode is invalid

Sounds to me you need a console operating and the CMD most likely gives you that.
The only true wisdom is knowing you know nothing

ASBzone

  • Hero Member
  • *****
  • Posts: 714
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: FreePascal doesn't run my programs (any)
« Reply #4 on: August 19, 2024, 06:15:03 am »
The thing is, I don't wanna wipe that Windows just because FP has a tiny snag.

Does everything else work properly in that partition?

I suspect that there is a bigger problem with the partition itself.

Also, it would help us to know what code you are compiling, to what platform type. 

And when you say "you cannot run the shell," I think it would be very helpful if you would provide more clarity on that.  What shell?  What error message? What version of FPC and Lazarus?  What method of Install?   What specific edition of Windows 11?  And what else do you run there?

-ASB: https://www.BrainWaveCC.com/

Lazarus v3.5.0.0 (2216170cde) / FPC v3.2.3-1387-g3795cadbc8
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

Thaddy

  • Hero Member
  • *****
  • Posts: 16184
  • Censorship about opinions does not belong here.
Re: FreePascal doesn't run my programs (any)
« Reply #5 on: August 19, 2024, 07:08:51 am »
doserror 13 means permission denied. It is not likely to be caused by a damaged disk, although that is possible. If your drive supports S.M.A.R.T, use that to check the disk.
But usually it it just a rights issue.
It can be one of:
- windows rights for the user for that disk.
- accessing files or directories that are read-only
- file is in use
- file does not exist
- accessing a directory as a file

See the msdos documentation (except for the first)

In a fpc program you can compile a console app in {$I-} state and check IOResult. That would also be 13. (or any error from 17 downwards, which are all OS errors)
Alas, error 13 is not documented in the fpc documentation, which is an omission.
« Last Edit: August 19, 2024, 07:42:43 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

Thaddy

  • Hero Member
  • *****
  • Posts: 16184
  • Censorship about opinions does not belong here.
Re: FreePascal doesn't run my programs (any)
« Reply #6 on: August 19, 2024, 07:47:03 am »
Side note:
languages like Python handle that correctly as 13.
If I smell bad code it usually is bad code and that includes my own code.

TRon

  • Hero Member
  • *****
  • Posts: 3631
Re: FreePascal doesn't run my programs (any)
« Reply #7 on: August 19, 2024, 10:02:28 am »
fwiw the bingo game was won by Aruna  :)
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

Thaddy

  • Hero Member
  • *****
  • Posts: 16184
  • Censorship about opinions does not belong here.
Re: FreePascal doesn't run my programs (any)
« Reply #8 on: August 19, 2024, 11:35:03 am »
No, it isn't. My version is a bit more complete.
If I smell bad code it usually is bad code and that includes my own code.

TRon

  • Hero Member
  • *****
  • Posts: 3631
Re: FreePascal doesn't run my programs (any)
« Reply #9 on: August 19, 2024, 11:50:58 am »
@Thaddy: Except for the fact that you are referring to error code 12 (same as jamie did).

link
« Last Edit: August 19, 2024, 11:53:14 am by TRon »
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

Bart

  • Hero Member
  • *****
  • Posts: 5468
    • Bart en Mariska's Webstek
Re: FreePascal doesn't run my programs (any)
« Reply #10 on: August 19, 2024, 12:16:19 pm »
Since we have no reply from TS yet, let's just wait a bit.
All else is speculative.

Bart

Aruna

  • Hero Member
  • *****
  • Posts: 513
Re: FreePascal doesn't run my programs (any)
« Reply #11 on: August 19, 2024, 03:08:11 pm »
fwiw the bingo game was won by Aruna  :)
Guys, look what I found MS-DOS v1.25, v2.0, v4.0 Source Code

Thaddy

  • Hero Member
  • *****
  • Posts: 16184
  • Censorship about opinions does not belong here.
Re: FreePascal doesn't run my programs (any)
« Reply #12 on: August 19, 2024, 03:36:40 pm »
fwiw the bingo game was won by Aruna  :)
fwiw Bingo delay is due to switch from cable to fiber - and also mobile, and a different provider - and lack of connection between devices..
The modem is still missing so everything goes over mobile access points. Should be solved soon.
If I smell bad code it usually is bad code and that includes my own code.

fxeconomist

  • New Member
  • *
  • Posts: 48
Re: FreePascal doesn't run my programs (any)
« Reply #13 on: August 20, 2024, 09:23:37 am »
A picky point, no solution (you are very unlikely to get a windows solution from me !).

May be its a terminology issue but I am struggling to make sense of your report. Firstly, lets get this clear. You start with some source code, FPC complies that into an executable (Lazarus asks FPC to do it) and then Lazarus runs your program for you.

So, by my reckoning, your fix of a cmd file instead of fpc would make no difference when running the program (fpc is not, then, involved) but would possibly make a difference when compiling.

Now, if what you appear to be saying is literally true, your fix is somehow building a different binary at compile time, one that will run on your system.  Thats an important clue to what is happening.

I hope you don't think I am being awkward here, its just that what you seem to be describing is unlikely but, never the less, possible.

Could you clarify please ?

Maybe compile (ie "build", or even "clean up and rebuild") in both modes, with and without your fix, and see if the two binaries are different ?

Davo

I can show you the screenshots.
(https://i.postimg.cc/F1w9JnVb/fp-refuses-to-run-program.png)
(https://i.postimg.cc/65pTgk7P/fp-refuses-to-run-program.png)

(https://i.postimg.cc/Gt2rg1MJ/fp-cannot-run-shell.png)
(https://i.postimg.cc/r0vvz72K/fp-cannot-run-shell.png)

Now, I'm thinking it's gotta be something like a registry setting or a path. It would be nice if a dev could tell exactly what's in the fp code there to trigger these errors.

Now, if's a denied access - which is unexplainable - it reminds me of another problem that I have, which nobody found a solution for, in Lazarus. A big program of mine cannot overwrite files. So, once a file is saved thru the usual scheme : assign - rewrite - write stuff - close,
when the procedure is run again it returns error 5 on rewrite. Nobody found an explanation for that, but it doesn't piss me off greatly, least for now.
« Last Edit: August 20, 2024, 09:30:09 am by fxeconomist »

Bart

  • Hero Member
  • *****
  • Posts: 5468
    • Bart en Mariska's Webstek
Re: FreePascal doesn't run my programs (any)
« Reply #14 on: August 20, 2024, 10:08:45 am »
OK, so the fp IDE gives an error when you try to run the program from within the IDE, but you can run the program from the commandline just fine.

What's the content of your %COMSPEC% environment variable?
Does it matter on which drive the the program resides?

Bart

 

TinyPortal © 2005-2018