Recent

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

OkobaPatino

  • Full Member
  • ***
  • Posts: 197
[SOLVED] {$WAIT}
« on: December 02, 2020, 12:04:58 pm »
Is there a way to sue {$WAIT} while using Lazarus?
« Last Edit: December 05, 2020, 02:11:03 pm by OkobaPatino »

Thaddy

  • Hero Member
  • *****
  • Posts: 10754
Re: {$WAIT}
« Reply #1 on: December 02, 2020, 12:11:32 pm »
Derived from PHP {$wait}? what do you want to achieve?
Otherwise Lazarus supports breakpoints if that is what you mean

OkobaPatino

  • Full Member
  • ***
  • Posts: 197
Re: {$WAIT}
« Reply #2 on: December 02, 2020, 12:12:35 pm »
https://www.freepascal.org/docs-html/prog/progsu80.html#x87-860001.2.80

Just pause the compile in some cases and resume as I like.

Thaddy

  • Hero Member
  • *****
  • Posts: 10754
Re: {$WAIT}
« Reply #3 on: December 02, 2020, 12:13:55 pm »

OkobaPatino

  • Full Member
  • ***
  • Posts: 197
Re: {$WAIT}
« Reply #4 on: December 02, 2020, 12:16:23 pm »
Thaddy you are a funny guy :D
Yes, I know that, obviously. I was curious if it is possible to use WAIT with Lazarus.

rvk

  • Hero Member
  • *****
  • Posts: 4472
Re: {$WAIT}
« Reply #5 on: December 02, 2020, 12:18:11 pm »
https://wiki.lazarus.freepascal.org/IDE_Window:Breakpoints
Thaddy, I think you miss the point.
In FPC there is a {$WAIT} directive.
If you add that, the compiler stops at that point with compiling until you press enter.

You can do the same in Lazarus, and the message is in the message pane ("Press <enter> to continue").
But because the compiler doesn't have focus (and is hidden?) you can't really press enter for the compile process.

@OkobaPatino, also note the remark
Quote
Remark This may interfere with automatic compilation processes. It should be used only for compiler debugging purposes.
And Lazarus does an automatic compile.
So interrupting this, isn't really a good idea.
« Last Edit: December 02, 2020, 12:20:56 pm by rvk »

OkobaPatino

  • Full Member
  • ***
  • Posts: 197
Re: {$WAIT}
« Reply #6 on: December 02, 2020, 02:27:03 pm »
@rvk, you are right, and I like to use it in custom cases instead of doing things like readln. My question is about curiosity.

Zoran

  • Hero Member
  • *****
  • Posts: 1665
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: {$WAIT}
« Reply #7 on: December 02, 2020, 02:59:49 pm »
@rvk, you are right, and I like to use it in custom cases instead of doing things like readln. My question is about curiosity.

Do you understand that these two cannot be used for similar purposes?
{$wait} is a compiler directive, which pauses the compilation process, whereas ReadLn is a procedure, which is executed in runtime.

rvk

  • Hero Member
  • *****
  • Posts: 4472
Re: {$WAIT}
« Reply #8 on: December 02, 2020, 03:14:15 pm »
@rvk, you are right, and I like to use it in custom cases instead of doing things like readln. My question is about curiosity.
Indeed like Zoran says...

Can you give us some example of a custom case where you would need to pause the compiling process?

OkobaPatino

  • Full Member
  • ***
  • Posts: 197
Re: {$WAIT}
« Reply #9 on: December 02, 2020, 03:21:53 pm »
Of course, they are not equal.
This is an example. The include file is managed by another program and if soem condition is defined in that, I like to pause the compile in the middle so the user can do a task and then continue.
Code: Pascal  [Select][+][-]
  1. {$I CustomValueInclude.inc}
  2. {$IFDEF CustomValue}
  3. {$NOTE Please do the task and then continue}
  4. {$WAIT}
  5. {$ENDIF}    
As I said a handful of times, I am just curious about using it with Lazarus, it is not a critical problem.

rvk

  • Hero Member
  • *****
  • Posts: 4472
Re: {$WAIT}
« Reply #10 on: December 02, 2020, 03:28:38 pm »
This is an example. The include file is managed by another program and if soem condition is defined in that, I like to pause the compile in the middle so the user can do a task and then continue.
I'm not sure what kind of task the programmer can do at that point... (other than getting a cup of coffee  :P )
But I get your point.

The problem is that compiling is an internal process in Lazarus, so there is no interaction with the user during compiling.
You can look at the NOTEs in the messaging window after compiling (including with all the other errors, warnings and hints).

You can also put {TODO: custom_task} inside code where you need to still do some stuff.
View > ToDo List will give you all tasks in your project.

But that's different from pausing the compile process (which is AFAIK not possible in Lazarus).

OkobaPatino

  • Full Member
  • ***
  • Posts: 197
Re: {$WAIT}
« Reply #11 on: December 02, 2020, 03:38:14 pm »
I understand and thank you for getting my point. It has insignificant usage but useful nevertheless.

MarkMLl

  • Hero Member
  • *****
  • Posts: 2428
Re: {$WAIT}
« Reply #12 on: December 02, 2020, 04:00:47 pm »
Of course, they are not equal.
This is an example. The include file is managed by another program and if soem condition is defined in that, I like to pause the compile in the middle so the user can do a task and then continue.
Code: Pascal  [Select][+][-]
  1. {$I CustomValueInclude.inc}
  2. {$IFDEF CustomValue}
  3. {$NOTE Please do the task and then continue}
  4. {$WAIT}
  5. {$ENDIF}    
As I said a handful of times, I am just curious about using it with Lazarus, it is not a critical problem.

OK, so you might need to do that if you wanted to start a syscall trace immediately after the $WAIT point, or enable a breakpoint if debugging the IDE itself.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and 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: 10754
Re: {$WAIT}
« Reply #13 on: December 02, 2020, 06:42:07 pm »
https://www.freepascal.org/docs-html/current/prog/progsu80.html#x87-860001.2.80
Is local, so you can use $push/$pop.
And indeed it pauses compilation in FPC. I don't know if Lazarus handles it correctly, though. Seems that is the problem.
In plain FPC this works. Of course, after compilation - after pressing enter - has finished, you still need to run the program.
« Last Edit: December 02, 2020, 07:18:39 pm by Thaddy »

MarkMLl

  • Hero Member
  • *****
  • Posts: 2428
Re: {$WAIT}
« Reply #14 on: December 02, 2020, 07:43:55 pm »
https://www.freepascal.org/docs-html/current/prog/progsu80.html#x87-860001.2.80
Is local, so you can use $push/$pop.
And indeed it pauses compilation in FPC. I don't know if Lazarus handles it correctly, though. Seems that is the problem.
In plain FPC this works. Of course, after compilation - after pressing enter - has finished, you still need to run the program.

Obviously the example I gave was "scraping the barrel": I was just looking for some way that it might possibly be even minimally useful.

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.

I see just about zero chance of something like this ever being implemented, unless there are other useful implications that I've missed.

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

 

TinyPortal © 2005-2018