Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Happy holidays, How can I run a procedure then I press the ENTER key while being on Read Cycle?? 1

Status
Not open for further replies.

A_Radiolog_inFoxPro

IS-IT--Management
Mar 29, 2020
38
0
0
CY
Dear All ,

Happy holidays and all the best to all and a happy new year to everyone.

Now a peculiar request:
The code :
"
** Say something on screen
@ 1.5,24 say "*********" font "ARIAL" ,19 style "BU" color w+/g
** Say something more on screen
@ 5,24 say "***********" font "ARIAL" ,19 style "BU" color w+/g
** Draw me a text box to input my values
@ 10,60 GET some_variable pict '99999999999999999' color ,b+/w*,g/g font "Courier new",14 style ;
** Draw me some buttons to get the job done
@ 20,50 get ch function "*TH \<1. FIND;\<2. Find a different way;\<3. QUIT" font "ARIAL" ,13 style "b" size 2,25,0.5
** TH VS TV : - TH = Horizontal , TV - Vertical
** Get the answer of the user from ch procedure.
READ cycle
***Do case for every option.
"

Now the question is, I want a way to be able to as soon as I input a value in the text box and hit enter key to execute some other procedure down the line.
With any way I try to do it I am unable to type anything in the text box because the software runs in an infinite loop.(and always re-draws the box and everything.
Lastly I have several ways to search for my number so I want to have the main way of searching to an alternative ( that will be also used to work with the numbers on the buttons them selfs or I will make some letter being the shortcut. )

Don't ask me why I am using this palaeolithic way to create a form but this is the only way I manage to make this work ( the software is inherited by an old programmer that never has being optimised.)

Thank you in advance for all the help,
Merry Christmas and a Happy new year
The Doc
 
Hi Doc,
What version of FoxPro are you using?
There are WAY better ways to do what you're trying to achieve, but they depend on what version you are using.


Best Regards,
Scott
MSc ISM, MIET, MASHRAE, CDCAP, CDCP, CDCS, CDCE, CTDC, CTIA, ATS, ATD

"I try to be nice, but sometimes my mouth doesn't cooperate.
 
Happy new year,

What you write here makes more sense than the thread title, but overall this lacks some logic to me.

If I run it (after establishing variables "some_variable" and "ch", I get asked an input (number) and then can pick one of three options (button). Sometimes it repeats, sometimes not, I don't understand when and when not.

But you want the ENTER of the number to already act. Then why are you asking the user to pick one of three options? That always comes first, so your wish would be to noit have the three options and immediately react to the input of the number, then the @get function makes no sense.

I'd say if you don't want to repeat the same inputs, then remove the CYCLE, at least, the code after READ then runs. I can't really help here, though, VFP only supports one READ, the overall read of any events, it's not just stopping for one input, forms controls are all usable in parallel.

What I know about legacy program flow control is that there are several flavors of READ that either end with an input (i.e. ENTER) of a get or with a CLEAR, see an explanation here, maybe it helps:
Chriss
 
Dear All , Thank you for your time to help me out,

Scott24x7 said:
What version of FoxPro are you using?
FoxPro 6.0

Chris Miller said:
What you write here makes more sense than the thread title, but overall this lacks some logic to me.
Regarding the logic.
The idea is the Following.
I want to make an automated station that searches details of something via a barcode.
So the scanner sends a <CR> ( ENTER ) after reading said Barcode.
But because focus is on the text box a single <CR> just moves focus to the button. that was my issue.
All I wanted was to scan the barcode and execute the search procedure.
and also have the possibility to use the keyboard and mouse for input. That's why I wanted only <CR> to execute the search and not some automated way after losing focus for instance.

Let me know what you may come up with ,

Thank you in advance

The Doc
 
I alredy poointed out what happens, didn't I?

After the ENTER of the first GET the second GET runs.

You want to do something after the first GET, then you do it there, don't you?

I'd do a form a form has contorls like the textbox that have an event called VALID which would be what you could use. But that's solving your legacy screen code problem by moving away from it. You want to run old school screen code, then I actually can't help you to bring up the best practice, I don't find enough documentation about how such legacy @GETs and READs work.

I think you still want the input of a number AND the buttons to appear before going into the read mode, but then already react to the result of the first GET. I don't know actuallly, how that would work with the plethora of possible legacy code, as it's not found in modern VFP help topics. Sorry.

So you could do this:

Code:
@ 10,60 GET some_variable pict '99999999999999999' color ,b+/w*,g/g font "Courier new",14 style [b]
Read

? some_variable
* do something with this input:
Select * From products WHERE barcode = some_variable INTO cursor thebarcodeproduct
Do Case
   Case _tally=1
      ? 'The product is '+thebarcodeproduct.name
   Case _tally=0
      ? 'The Barcode is not found in the products data'
   Otherwise && _tally>1
      ? 'The Barcode is not unique, the products table needs to be fixed about this ambiguity-'
EndIf

But then the buttons would not appear.

Where I could help you with, is with a form, you have to find legacy FoxPro programmers to help you keeping old scholol screens working. I'm not even willing to learn how that would work, if I'm honest.

And I understand your situation, you have such code, not forms, you need to maintain this code and extend it, but this is like asking for help on a too old car. I can only wish you good luck in finding someone who still talks that old school dialect, I have no chance to even learn it, even if I would like to.

Chriss
 
Feel free to contact me if you want help with upgrading your application to VFP9, using the latest VFP technology.
 
Hey Doc,

I think you may be able to find a copy of FP 2.x on ebay or some other platform, from which the manual and documenation of all the commands would be the most helpful. As far as I remember even in VFP6 the help topics on legacy commands all just point out these are supported for backwards compatibility and to use forms or whatever other modern replacement. But there is no explanation of them in the help files of VFP versions, so that documentation is only available within the original older FoxPro versions.

Once, on the occasion of an anniversary of a software product I helped converting from VFP6 to 7 and later VFP9 with SQL Server backend, two complete rewrites on the way with paradigm changes of some application features and data migrations, someone gave me such an old FP version on 3.5" disks, that's the only contact I had with such old FoxPro versions.

The only thing I remember about screens are not even coming from this software project, so even not in the oldest version of it I picked up maintaining. I only came across code like yours from participating in the community and newsgroups back 15 years and longer ago. The solution I gave you introducing a single simple READ would work, but doesn't give you that full appearance of the screen including the ability of the user to use the buttons besides entering or scannning in the number. This kind of parallelism I think is not impossible in legacy screes, but they are surely always designed with a workflow in mind that would go one step after the other.

It's totally simple, on the other hand to have a form with a textbox that would react to a full barcode automatically or wait for the user to click a button in parallel, since Visual FoxPro and the forms you can do with VFP have the concept of parallel form control usage built in, each control has own events. Well, you know from any other Windows applications you can click forth and back between form elements. So what you ask here is easy too do with forms and controls like the textbox. You should really consider conversion of your application, maybe with the help oif Tore's offer.

Seeing one such sample is to little to say how doable it is to convert what you have. It might work to use conversion tools that came with FP3, but I guess VFP6 can't offer that, so to make the move you have skipped too many versions, keeping a codebase up to date is best done moving from version to version, VFP has had conversion tools from screens to forms, but I think these are not part of VFP6. Well, and these conversions also had one major choice, either you get a visual convewsion or a functional, so you had to sacrtifice the other aspect and reprogram anyway.

As you already mentioned your codebase is mainly undocumented, it's obviously not simple to make a transition and you could also think of completely retiring this and going for another software. You cornederd yourself into this, I guess that has become clear already earlier.

Chriss
 
@ GET supports a VALID clause that lets you run code. Have VALID call a routine that does whatever you want it do.

Tamar
 
Chris Miller said:
it's obviously not simple to make a transition and you could also think of completely retiring this and going for another software. You cornederd yourself into this, I guess that has become clear already earlier.

Unfortunately , I tried. The end user is reluctant because it just works. Its tailor made to their specifications.

Anyway as a work around that I got while sleeping on the damn problem was to simply program my barcode scanner to just ad a <TAB> AND A <CR> for the first barcode
and if second option needs to be executed some other prefix on the barcode is added to distinguish between the 1 <TAB> AND 2 <TAB> situations to give focus to button 2.
This is all done via 123Scan software of Zebra scanners by having rules of output. so in essence consider the situation resolved by other means other than foxpro it self. A cheeky work around.

Thank you for all the amazing support and taking your time to help me out in my endeavours ,

Thank you again for everything and with you health and prosperity in the new 2024 :)

And Wish you to stay away from doctors. Be healthy , Take care

The_Doc
 
Thanks Tamar,

I don't know when I will ever use this, but you never know.

Code:
some_variable=0
ch=''

** Say something on scr3243254een
@ 1.5,24 say "something" font "ARIAL" ,19 style "BU" color w+/g
** Say something more on screen
@ 5,24 say "somethiung more" font "ARIAL" ,19 style "BU" color w+/g
** Draw me a text box to input my values
@ 10,60 GET some_variable pict '99999999999999999' color ,b+/w*,g/g font "Courier new",14 style [b] VALID findproduct()

** Draw me some buttons to get the job done
@ 20,50 get ch function "*TH \<1. FIND;\<2. Find a different way;\<3. QUIT" font "ARIAL" ,13 style "b" size 2,25,0.5
** TH VS TV : - TH = Horizontal , TV - Vertical
** Get the answer of the user from ch procedure.
READ cycle
***Do case for every option. 


Procedure findproduct()

? some_variable
* do something with this input:
Select * From products WHERE barcode = some_variable INTO cursor thebarcodeproduct
Do Case
   Case _tally=1
      ? 'The product is '+thebarcodeproduct.name
   Case _tally=0
      ? 'The Barcode is not found in the products data'
   Otherwise && _tally>1
      ? 'The Barcode is not unique, the products table needs to be fixed about this ambiguity-'
EndIf



Chriss
 
Doc said:
The end user is reluctant because it just works. Its tailor made to their specifications.

What does it help if you come to a point where you can't maintain it`

Chriss
 
Chris Miller said:
What does it help if you come to a point where you can't maintain it`

That will show in the future. (that they will need some crazy solution, that I can't implement at all)

For the time being I am scarping by.

The needs must change radically for them to be be forced to change. That ain't going to happen. Any time soon.

Thank you again for everything and your time and effort.

The Doc
 
Finally after 10 hard days I managed to get my subroutine done , thank to you !

Thank you for your valuable help and valuable time and knowledge.

Thanks again.

The Doc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top