View previous topic :: View next topic |
Author |
Message |
rogerh
Joined: 02 Nov 2014 Posts: 46 Location: Longmont, CO
|
Posted: Tue Apr 07, 2015 6:11 am Post subject: |
|
|
Here's my shot at an interruptable wait routine.
It won't compile. Says DO is not labeled but END DO is.
I don't get it.
Roger
program keys
integer:: kv
do chk
call sleep1@(2)
call get_key (kv)
select case (kv)
case (0) ! NO KEY
exit select
case (27) ! ESC
exit check
case (368) ! F1
print *, kv
case default
end select
end do chk
end |
|
Back to top |
|
|
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Tue Apr 07, 2015 6:39 am Post subject: Re: |
|
|
rogerh wrote: |
It won't compile. Says DO is not labeled but END DO is.
|
Change
to
and try again. |
|
Back to top |
|
|
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Tue Apr 07, 2015 12:00 pm Post subject: |
|
|
Could you tell us more, what are you trying to achieve? Do you really need to sleep at all?
Why Perl needs to call Fortran routine? What Fortran routine needs to do?
If Fortran program needs to process some data file when its changed or created, then you could ask the file system to selectively notify you about changes. |
|
Back to top |
|
|
rogerh
Joined: 02 Nov 2014 Posts: 46 Location: Longmont, CO
|
Posted: Tue Apr 07, 2015 2:29 pm Post subject: |
|
|
Thanks!
This works. The problem was that I could find no explanation for naming the DO in the help file.
print *,"Start sleep"
chk: do
call sleep1@(2)
call get_key@ (kv)
select case (kv)
case (27) ! ESC
exit chk
case (368) ! F1
print *, kv
case default
end select
end do chk
print *,"End sleep"
Now I'll add things to do when the key is pressed.
Roger |
|
Back to top |
|
|
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Tue Apr 07, 2015 5:49 pm Post subject: Re: |
|
|
rogerh wrote: |
Now I'll add things to do when the key is pressed.
|
I still would like to know your final goal!
I am not convinced that you actually need to sleep or wait for a key in your Fortran program.
I don't know Perl, but here is a simple REXX example: REXX calls compiled PL/I program to solve a Sudoku puzzle, and then outputs solution. This works at least with free Regina REXX. PL/I source and binary for the Sudoku solver is included with the package.
Code: |
/* REXX calling compiled PL/I program to solve Sudoku */
/* Push Sudoku puzzle to solve into external data queue */
/* We could also let user type it interactively instead */
/* Put this will do for now... */
queue '000590000230004001000800003002000000050002006416700080807000000009067034000000079'
/* Assign puzzle into param variable */
parse pull param .
/* Execute and display the result */
'echo ' || param || '| sudoku | rxqueue'
do while queued() \= 0
parse pull line
say line
end
exit 0
|
|
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2822 Location: South Pole, Antarctica
|
Posted: Tue Apr 07, 2015 9:15 pm Post subject: |
|
|
Same functionality, looks better, no sleep needed
Code: | integer, external :: OnF1
i=winio@('%ww%ca[In Windows]%es%ff&')
i=winio@('%ac[F1]&', OnF1)
i=winio@('%cn%bt[OK]')
End
Integer function OnF1()
print*,' F1 pressed'
OnF1=2
end function |
|
|
Back to top |
|
|
rogerh
Joined: 02 Nov 2014 Posts: 46 Location: Longmont, CO
|
Posted: Tue Apr 07, 2015 10:22 pm Post subject: |
|
|
You guys are away over my head.
I can't even read the code.
Roger |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2822 Location: South Pole, Antarctica
|
Posted: Tue Apr 07, 2015 11:50 pm Post subject: |
|
|
Do not read, try it. And pass to your client to try, he might like it |
|
Back to top |
|
|
rogerh
Joined: 02 Nov 2014 Posts: 46 Location: Longmont, CO
|
Posted: Wed Apr 08, 2015 2:50 am Post subject: |
|
|
Ok, I tried it.
A console window opens. a little windows box opens with an OK button.
F1 is ignored
Clicking on OK closes the window.
Am I missing something?
Roger |
|
Back to top |
|
|
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Wed Apr 08, 2015 6:52 am Post subject: |
|
|
My point was to demonstrate that if the main program is written in Perl and calculations are done in Fortran to speed things up, then Fortran program can be just a simple console program. Conversation between Perl and Fortran programs can be done by simply piping standard input and output between programs.
I updated my previous REXX demo. It now also displays the number of solutions for the Sudoku puzzle. Program can solve any valid Sudoku.
example output:
Code: |
Calculated the number of solutions: 1
Time: 0.0460 seconds
Sudoku solved! Time: 0.0140 seconds
1 7 4 5 9 3 2 6 8
2 3 8 6 7 4 5 9 1
6 9 5 8 2 1 7 4 3
9 8 2 4 1 6 3 5 7
7 5 3 9 8 2 4 1 6
4 1 6 7 3 5 9 8 2
8 6 7 3 4 9 1 2 5
5 2 9 1 6 7 8 3 4
3 4 1 2 5 8 6 7 9
|
|
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2822 Location: South Pole, Antarctica
|
Posted: Wed Apr 08, 2015 2:10 pm Post subject: |
|
|
F1 is ignored? Really?
ESC does not work?
/* Looks like my type person. If you also lose your phone and keys welcome to my club. I lose and couldn't find everything. |
|
Back to top |
|
|
rogerh
Joined: 02 Nov 2014 Posts: 46 Location: Longmont, CO
|
Posted: Wed Apr 08, 2015 8:55 pm Post subject: |
|
|
DanRRight;
Lose things? I do worse than that. The other day my son came for a visit. When he was ready to leave he couldn't find his keys. We tore the house apart looking for them. Finally loaned him my car to go to work.
Next day looked again. No luck Then while changing clothes we found them - in my pocket!
Roger |
|
Back to top |
|
|
rogerh
Joined: 02 Nov 2014 Posts: 46 Location: Longmont, CO
|
Posted: Wed Apr 08, 2015 9:04 pm Post subject: |
|
|
Finally found out why the client wants this stuff. He wants to generate some data and plot it. Fortran should sleep while the user examines the plot, so the PC won't be tied up. Then at a keypress, Fortran will scroll the plot up or down as needed or quit.
Now he wants to know if FTN95 can send a keypress to Windows.
Sheesh!
Roger |
|
Back to top |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Thu Apr 09, 2015 2:33 am Post subject: |
|
|
Roger, did you get Dan's code to work ? Worked fine when I tried it.
Maybe you didn't spot it prind 'F1 pressed' IN THE CONSOLE WINDOW ?
Try putting WINAPP (on its own on a new line) at the top of the program and it'll print it into a default size output window instead.
Dan's code simply implements the Accelerator key %ac method Eddie (LitusSaxonicum) mentioned on the other thread.
When the F1 key is pressed the function 'OnF1' is executed which prints the message.
So, any code which you need to do something needs to go in that function (you can put calls to other seperate routines to do that rather .
You said: Quote: | Then at a keypress, Fortran will scroll the plot up or down as needed or quit |
Not sure what you mean by 'will scroll the plot up' do you mean the plot will be larger than the window, or do you mean 'scroll through several plots' ?
It also becomes relevant here how the plots are produced, either via a call to that Perl program or within FTN95(Clearwin+) which was mentioned on another post.
(Relevant only in the sense of how best to structure the part of the program written in Ftn95/Clearwin)
As anyone will tell you, half the problem of writing any windows gui program is working out what you want to do exactly first and then planning its structure accordingly. This is why Eddie mentioned the importance of knowing exactly what you want to do on the other post.
As for examples, there are examples there in the documentation, all over the place, the problem is that even if they were all gathered together in one place you'd still never find exactly the code you're looking for because they depend on the context of the problem.
They need to be adapted for any particular use. Inevitably that's where the user has to do a certain amount of reading up in order to understand even approximately what some of the experienced users are on about sometimes. It's a natural learning progression. The unfortunate thing in your case is that you appear to be under pressure from your client to produce a solution rapido. These 2 things are incompatible , no matter what windows gui program you would 'pick up' unless you have 10+ years of experience with it (i.e. already know the code).
In my short experience with FTN95 I've seen that virtually ANYTHING is possible using it ... but to actually write the code to do it and implement it obviously takes a little longer.
My advice to you as a starter is do what I did first ... READ ALL THE DOCUMENTATION (best to PRINT it out !) . It obviously won't all (or even in part) stick in the brain cell, but it gives you a certain memorisation of how the documentation is structured and roughly WHERE things are. This will help no end when searching for stuff. You'll also see lots of simple examples demonstrating the use of simple commands !
Second thing to do .. the classic RTFMA ... read the flipping manuals again !
Slowly at first, you'll begin to understand more and more of what's written on the forum. |
|
Back to top |
|
|
rogerh
Joined: 02 Nov 2014 Posts: 46 Location: Longmont, CO
|
Posted: Thu Apr 09, 2015 2:56 am Post subject: Re: |
|
|
John-Silver wrote: | Roger, did you get Dan's code to work ? Worked fine when I tried it. |
No, but it isn't needed now.
Quote: |
Maybe you didn't spot it prind 'F1 pressed' IN THE CONSOLE WINDOW ?
Try putting WINAPP (on its own on a new line) at the top of the program and it'll print it into a default size output window instead.
Dan's code simply implements the Accelerator key %ac method Eddie (LitusSaxonicum) mentioned on the other thread.
When the F1 key is pressed the function 'OnF1' is executed which prints the message. |
That isn't the intent.
Quote: | So, any code which you need to do something needs to go in that function (you can put calls to other seperate routines to do that rather .
You said: Quote: | Then at a keypress, Fortran will scroll the plot up or down as needed or quit |
Not sure what you mean by 'will scroll the plot up' do you mean the plot will be larger than the window, or do you mean 'scroll through several plots' ? |
The plot if printed would be about 4 feet long.
Quote: |
It also becomes relevant here how the plots are produced, either via a call to that Perl program or within FTN95(Clearwin+) which was mentioned on another post. |
Ideally, with Clearwin+ once I learn enough about it.
Quote: | (Relevant only in the sense of how best to structure the part of the program written in Ftn95/Clearwin)
As anyone will tell you, half the problem of writing any windows gui program is working out what you want to do exactly first and then planning its structure accordingly. This is why Eddie mentioned the importance of knowing exactly what you want to do on the other post.
|
Understood and that's why I refused to do it for him (my client). I know how complicated it can be and I don't write windows programs anyway, just programs that can run in Windows PCs.
Quote: |
As for examples, there are examples there in the documentation, all over the place, the problem is that even if they were all gathered together in one place you'd still never find exactly the code you're looking for because they depend on the context of the problem.
They need to be adapted for any particular use. Inevitably that's where the user has to do a certain amount of reading up in order to understand even approximately what some of the experienced users are on about sometimes. It's a natural learning progression. The unfortunate thing in your case is that you appear to be under pressure from your client to produce a solution rapido. These 2 things are incompatible , no matter what windows gui program you would 'pick up' unless you have 10+ years of experience with it (i.e. already know the code). |
The problem with docs is that they're written by people who are most familiar with the language and tend to think everyone is as knowlegable as they are. Usually the hard part is finding out what something is called.
Quote: |
In my short experience with FTN95 I've seen that virtually ANYTHING is possible using it ... but to actually write the code to do it and implement it obviously takes a little longer. |
Actually I've found translating TrueBasic to FTN95 is fairly easy until something exotic comes up. Then I don't know what to look for.
Quote: |
My advice to you as a starter is do what I did first ... READ ALL THE DOCUMENTATION (best to PRINT it out !) . It obviously won't all (or even in part) stick in the brain cell, but it gives you a certain memorisation of how the documentation is structured and roughly WHERE things are. This will help no end when searching for stuff. You'll also see lots of simple examples demonstrating the use of simple commands !
Second thing to do .. the classic RTFMA ... read the flipping manuals again !
Slowly at first, you'll begin to understand more and more of what's written on the forum. |
|
|
Back to top |
|
|
|