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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP 6 Create button on dev screen 2

Status
Not open for further replies.

eric43

Programmer
Apr 29, 2005
94
AU
Is it possible to save typing 'Do Main' each time I want to test run my code ?

Can I create a button on the ToolBar to do this?

Many thanks

Eric
 
Eric,

A few ideas:

- Add a custom menu to the main system menu. Include commands for the things you want to do most often, such as DO MAIN. Give those commands their own shortcut keys.

- Create a keyboard macro. Save it in an FKY file. Add code to your startup routine to load that file. (See for more details.)

- Open Main.Prg in the code editor. Click on the Run button (the big red exclamation mark) to run the program. When the run has finished, the code editor will still be open. You cna do whatever you need to do, then click the same button again.

- Type DO MAIN the first time you want to run the program. Thereafter, scroll back to the command in the command window and hit Enter (this one is my own preferred method; usually, you only need to hit the up arrow key a couple of times to get back to the command in question).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Guys,

Star to Mike for his very expansive answer and Chris for his.

Eric
 
A slightier flashier alternative to Mike's solutions is to put a button on the screen itself:

Code:
Public oHandler

oHandler=Newobject("ClickHandler")

With _Screen
  .AddObject('cmdStart', 'commandbutton')

  Bindevent(_Screen.cmdStart,"Click",oHandler,"myClick")

  With .cmdStart
    .Caption = "Start"
    .Top = 10
    .Left = 10
    .Height = 27
    .Visible = .T.
  Endwith

  Return
Endwith

Define Class ClickHandler As Session
  Procedure myClick
    Messagebox("Hello Mum")
  Return
Enddefine

Put this code in your startup routine and the button will be there as Fox appears. You would of course have the click handler do something more useful than put up a messagebox.

Use _screen.RemoveObject("cmdStart") to get rid of the button.


Geoff Franklin
 
I have a simple set of prg files that do this for me.

I use a file called b.prg that I invoke by:
DO B

B.PRG has:
build app race.app from race
do race.app

Since I rebuild the program hundreds of times a week I use the simplest keystrokes possible.

Don


Don Higgins
 
Custom InteliSense is the way to go (I think VFP7+).

e.g. tools -> IntelliSense Manager -> Custom -> in "Replace" type "hi" -> in "With" type "{hi}" -> click on "Add" -> click script and paste:

Code:
LPARAMETER oFoxcode
oFoxcode.valuetype="V"

messagebox([Hello Eric])
*do c:\MyPath\MyProg\Main.prg

RETURN chr(42)+[ Eric's Main.prg was launched]

Back in the command window type 'hi ' or 'hi' and 'enter'

Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top