Recent

Author Topic: [SOLVED] {$WAIT}  (Read 4374 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: {$WAIT}
« Reply #15 on: December 02, 2020, 08:55:44 pm »

I suspect that since it effectively puts the compiler in a locked up state, passing that state back to the IDE would- on unix at least- involve coopting a signal e.g. HUP or USR1; the IDE could have a handler which might possibly be a good place for somebody trying to find a very difficult bug to hang a breakpoint.
The chance is 100% since it is already implemented..... <sigh> To be frank: I had to test that (<sigh to me that I forgot>
Only caveat is if you want to run after the wait: that seems to be incomplete. It only resumes the compile even if asked to run as well, but compilation finishes.
Under FPC and a terminal it actually works pretty good. It is the <enter> key in Lazarus that does not seem to respond.
That should be fixable. It also works when running through GDB. Definitely a Lazarus IDE issue.
QED:
Code: Pascal  [Select][+][-]
  1. {$mode delphi}{$H+}
  2. var i:integer = 10;
  3. begin
  4. {$wait}
  5. writeln(i);
  6. end.
Code: Bash  [Select][+][-]
  1. ~ $ fpc waitforme.pas
  2. Press <return> to continue
Now press return ... and run...
Code: Bash  [Select][+][-]
  1. ~ $ ./waitforme
  2. 10
I am pretty sure that can be fixed for Lazarus as well. It works, but please also note my previous remark and the documentation: it is for debugging only,.

« Last Edit: December 02, 2020, 09:12:47 pm by Thaddy »
Specialize a type, not a var.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: {$WAIT}
« Reply #16 on: December 02, 2020, 10:02:44 pm »
Works in FPC... but the question is whether the Lazarus IDE can do something useful with it. I suppose the IDE could recognise FPC's output text, in which case the <Enter> would presumably have to be in the messages window.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: {$WAIT}
« Reply #17 on: December 02, 2020, 10:18:44 pm »
No the debug window or the message window should handle that and it needs focus of course.
Anyway it works for FPC. It is Lazarus that does not handle it. (Geany handles it.....)
« Last Edit: December 02, 2020, 10:25:00 pm by Thaddy »
Specialize a type, not a var.

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: {$WAIT}
« Reply #18 on: December 02, 2020, 10:22:09 pm »
The problem is probably what window has focus.
The message window could display a showmessage dialog at that point.
But after that it should also send the compiler process the asked enter-key.

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: {$WAIT}
« Reply #19 on: December 02, 2020, 10:26:51 pm »
No Rik, it has to do with the focus, granted, but has also to do with context (for pressing return). That status should be cached.
Specialize a type, not a var.

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: {$WAIT}
« Reply #20 on: December 02, 2020, 10:46:34 pm »
No Rik, it has to do with the focus, granted, but has also to do with context (for pressing return). That status should be cached.
O, no. I didn't mean that the focus is the problem at this moment.
Lazarus just runs the compiler hidden and rerouted output to itself to determine what to display in the message window. There is no input whatsoever programmed there for the compiler.

I meant, for implementing this in Lazarus, the problem would be focus. When focus is on the code window, the enter would go there.

So my suggestion would be for the message window to recognize the <enter> and then display a dialigbox, so the focus is definitely on the dialog box.
After that, the message-window should also send the enter to the compiler progress.

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: {$WAIT}
« Reply #21 on: December 02, 2020, 10:57:55 pm »
Yes. We totally agree here...
Specialize a type, not a var.

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: {$WAIT}
« Reply #22 on: December 03, 2020, 07:56:25 am »

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: {$WAIT}
« Reply #23 on: December 03, 2020, 09:10:52 am »
https://www.freepascal.org/docs-html/current/prog/progsu80.html#x87-860001.2.80
Is local, so you can use $push/$pop.

First of there is no state that could be pushed or popped related to this directive.

Second: a directive being local does not automatically mean that it's state can be saved with $push/$pop. Only selected directives support that (though I do try to increase their number when I find one).

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: {$WAIT}
« Reply #24 on: December 03, 2020, 09:17:27 am »
IMO there is no reason for Lazarus (which simply redirects and filters fpc messages to it'own GUI messages window) to implement user input for that.
If you really, really, really need the {$WAIT} directive then you can build the application from the commandline.

Bart

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: {$WAIT}
« Reply #25 on: December 03, 2020, 09:35:31 am »
As the documentation states it's mainly for compiler development anyway.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: {$WAIT}
« Reply #26 on: December 03, 2020, 10:06:44 am »
IMO there is no reason for Lazarus (which simply redirects and filters fpc messages to it'own GUI messages window) to implement user input for that.
If you really, really, really need the {$WAIT} directive then you can build the application from the commandline.

In that case the IDE should be swatting the request as soon as it sees it. Having something in Pascal source which can lock up the IDE is unacceptable, particularly now that Google will pick up this discussion and some damnfool will think he's got a good reason to try it.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: {$WAIT}
« Reply #27 on: December 03, 2020, 10:11:23 am »
At least, it is not a bad idea to inform the user why IDE hangs and shows a message (ask for key enter) that you can not do anything except stopping the compilation.
@MarkMLl, I think many people tried it by now, no matter this topic, and spent a while trying to find a workaround and dropped it. I am raising these issues to have them for the future and maybe give them a fix or a result.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: {$WAIT}
« Reply #28 on: December 03, 2020, 10:19:51 am »
@OkobaPatino I assure you that I was not lumping you into the "damnfool" category: I think you've raised a useful point :-)

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: {$WAIT}
« Reply #29 on: December 03, 2020, 10:22:04 am »
Of course!

 

TinyPortal © 2005-2018