You are on page 1of 16

PRE201: Introduction to Visual FoxPro

This Workshop introduces you to Visual FoxPro and the basics o ho! to use it" Plan to attend this session i you#re a be$innin$ Visual FoxPro de%eloper or you ha%en#t !orked in Visual FoxPro be ore& and you !ould like to $et 'ore out o the (e%)on that ollo!s"

In the be$innin$& !as the dot
What is Visual FoxPro?
 

It’s a standalone tool for data manipulation It’s a development tool for standalone, LAN, client-server, applications It’s a data#ase en$ine It’s a pro$rammin$ lan$ua$e It’s part of Visual %tudio It’s an inte$ral part of "icrosoft Windo&s It’s a reli$ion !" and We#

    

Well, 'es and no( )he first four are pro#a#l' true( )he last three are pro#a#l' not, althou$h 'ou ma' find adherents &ho #elieve some, all, or none, of those statements( )he' also sa' there’s one #orn ever' minute( Let’s di$ a little, startin$ &ith a little histor' lesson( Wa'ne *atliff &as the pro$rammer, &or+in$ for "artin "arietta and su#contractin$ for the ,et Propulsion La#orator', &ho started to create a natural-lan$ua$e-st'le data#ase en$ine and manipulation lan$ua$e on his I"%AI -.-. computer, in assem#ler, in his spare time, in order to improve his chances in the foot#all pool( !ne thin$ lead to another, and he &as soon mar+etin$ the product as d/A%0( It &as purchased #' Ashton-)ate, then /orland, and is no& o&ned #' d/A%0, Inc( It &as one the +e' products in the ma+in$ of the 1P *evolution2 of the 34-.s that lead to a P on ever' des+( In its he'da', a num#er of lan$ua$e-compati#le 1clones2 such as Fox/ase, lipper, d#"AN and man' others competed fiercel' for the hearts and minds and &allets of developers( Fox %oft&are, #ased in Perr's#ur$, !hio, &as formed and run #' 5r( 5avid Fulton( 615r( 5ave2 as he &as affectionatel' +no&n, &as a $reat sho&man, &ho deli$hted in meetin$ and presentin$ to his customers( 7e is a ma8or reason that 5ev on continues to this da'(9 Fox %oft&are created a fast, interpreted version of the d/A%0 runtime and then #ro+e the mold in $oin$ #e'ond the standard to introduce man' additional features( Fox/ase ran on "ac, 5!% and :nix platforms( FoxPro, startin$ &ith version ;(<, supported Windo&s as &ell( Fox %oft&are &as ac=uired #' "icrosoft in "arch of 344;( While there &as a "acintosh version of Visual FoxPro >(., su#se=uent versions run onl' on the Windo&s platforms( In this paper, I loo+ at ho& to learn Visual FoxPro( "asterin$ a computer lan$ua$e is similar to masterin$ another s+ill( ?ou need to pro$ress throu$h the levels of novice,

datetime 6a com#ination of date and time9.. currenc' lo$ical 6true or false9.3 A collection of these records &ould form a table( )he ta#le of data can #e vie&ed in man' &a's. #ut are rarel' used( A collection of fields &hich hold a sin$le piece of information are $athered to$ether to form a record( For example.. dou#le. control and o#8ects that #uild applications( Finall'. numeric. I loo+ at the lan$ua$e itself.apprentice. 'ou mi$ht record a chec+ received from a customer asE Field name ustomer Num#er hec+ Num#er Amount 5ate *eceived Type Inte$er Inte$er Numeric 64.ul' . a re$ion code. inte$er. #ut the standard form used #' the Fox /*!W%0 command loo+s li+e thisE ustom er hec + Amou nt 5ate . and provide a perspective and philosoph' of ho& an entire application should #e put to$ether( Part I * It+s the (ata /efore &e can plun$e headfirst into developin$ FoxPro applications. memo 6ver' lon$ freeform text or #inar' data9( %pecialiDed datat'pes exist to hold !L0 information 6$eneral fields9. date. and don’t need to #e su#-divided &hen 'ou are processin$( For example. "acintosh #inar' 6picture fields9. I loo+ at data.>B. float. ho& to interact &ith the data. such as AN->>AB-3.(33 . a $lossar' and a #it of a#stract theor' &ill ma+e the applications &or+ much #etter( Terminology A field is a sin$le piece of information. if 'our part num#er is composed of a part t'pe. and that is &hat I tr' to cover here( First. it can often #e #etter to #rea+ that information into separate fields and com#ine it &hen needed. the fourth section tries to pull to$ether all of the previous sections.3 <FGH43. as is it the data that is reall' &hat it is all a#out @ the application is 8ust a &a' to #etter mana$e the data( %econd. . such a person’s first name or an item’s price( 5ivide up 'our information so that fields can stand on their o&n... nor covered in a short paper( /ut master' starts &ith a $ood understandin$ of the fundamentals. rather than tr' to #e constantl' splittin$ the field &hen loo+in$ for all parts from one re$ion( 0ach field has a sin$le datatype( 5ata t'pes hold a particular +ind of informationC have upper and lo&er limits on their capacit'C and are restricted on &hat information the' can hold( Fields ma' #e character. read it in and displa' it( )he third section $oes #e'ond the #asic procedural parts of the lan$ua$e into the po&er tools. a ratin$ and a su#-part num#er. and 8ourne'man to reach the master level( Achievin$ master' is not a su#8ect that can #e tau$ht in a mornin$.9 5ate Data B>.

&' ) -!CREATE TABLE CheckRec !ROM ARRA/ a!"e # 0ach of these &a's of creatin$ a ta#le has advanta$es and disadvanta$es( )he first is easiest for a #e$innerC he or she is $uided in the choices to #e made( )he second is =uic+erC one line of t'pin$ and 'ou’re done( )he third form. or no &a' at all( )o create this ta#le &e mi$ht t'peE CREATE And let the user interface $uide us to &hat &e &anted to create( !r &e could t'peE CREATE TABLE CheckRec (Customer I.3I34 .(' ) *Customer* a!"e #$(.(' ) *CheckNo* a!"e #$2.(' ) *Amount* a!"e #$+. a!"e #$%.>..+' ) % a!"e #$(.2).3.%' ) ..&' ) -!a!"e #$%. >>B> B>(>B .&' a!"e #$(.2' ) *D* a!"e #$%.(' ) *ChkDate* a!"e #$%. .3 .. a!"e #$2. there are usuall' three &a's to do an'thin$.> )his $eometr' leads to other names for the items.>.3 B>.&' ) -!a!"e #$+.&' ) -!a!"e #$2..B> >. .%' ) 2 a!"e #$+.+' ) 9 a!"e #$+. a!"e #$(. thou$h. >3.B > B.%' ) . a!"e #$%.I.2' ) *I* a!"e #$2.>I.3I.2' ) *I* a!"e #$(. Check I.+' ) % a!"e #$2.&' #"mens"on a!"e #$%.>.+' ) . Amount N(9. . 'ou face the tas+ of determinin$ &hat $oes &here( %hould all of the data #e on one lar$e ta#le or should the information #e sorted into several smaller ta#les? .>I34 .2' ) *N* a!"e #$+.I.%' ) . records are often called rows and fields columns. . Date D) !rE DIMENSION a!"e #$%. In FoxPro.>. leads to the most flexi#ilit' and control( Design and Normalization No& that 'ou have a #asic $rasp on ho& to create ta#les of data.

tat iEmpStatPK:I cESCode:C(!") cES0esc:C(/") lESInact:L requires 3ob)ate$ belongs to iJobCatPK:I c8o CCode:C(!") c8o C0esc:C('%) l8o CInact:L )liRate determines iCliRatePK:I i8o CatFK:I iClientFK:I nCRRate:N(-7#) describes Task iTaskPk:I c4as3Code:C(!") fills c4as30esc:C(#%) l4as3Inact:L 3ob 3obTask describe iJobTaskPK:I i4as3FK:I i8o FK:I has iJobPK:I consists of iClientFK:I i0eptFK:I i8o CIBFK:I i8o SuprFK:I i8o BillFK:I i8o CatFK:I i8o StatFK:I t8o Start:4 t8o End:4 c8o Num:C(!") c8o Rpt4oF:C(!") c8o Rpt4oL:C(!%) c8o Rpt&C:C(') c8o Rpt*+n:C(8) c8o RptE. then those items $o into a second ta#le( )a#les are related to one another #' a description of ho& information in one ta#le is associated &ith information in another( In the order example.. some or man' other records one-to-oneE data split across several ta#les for performance )hese relationships defined in the desi$n sta$e &ill not #e of much use if the people usin$ the data#ase s'stem can add.aury -roup& Inc" Place'ent (ata .t:C(-) cClFa.p&0*:0 dE. APPEND BLANK.kill make up iJobSkilPK:I i8o FK:I iS3illFK:I c8SLe1el:C(!) )liEn%i Describes iCliEnviPK:I cCECode:C(!") cCE0esc:C(/") lCEInact:L E'p.pIn1:0 tB3Entry:4 tB3$odify:4 cB39ser:C(!") can have describes has Results in )ontact iContactPK:I iClientFK:I iRoleFK:I cCntCode:C(#) cContact:C('") cCntFirst:C(#") cCntLast:C(#") cCnt&ddr!:C('") cCnt&ddr#:C('") cCntCity:C(#%) cCntState:C(#) cCnt)ip:C(!") cCnt*+n&C:C(') cCnt*+one:C(!') cCnt*+nE.&C:C(') cCntFa.:C(!') cCntEmail:C(/") dCnt0.t:C(-) cEmp&lt&C:C(') cEmp&lt*+n:C(8) cEmp&ltE.tat describes iClC StaPK:I cCCCode:C(!") cCC0esc:C(#") lCCInact:L E'pRecru iEmpRec PK:I cEmpRCode:C(!") cEmpR0esc:C('") lEmpRInact:L E'ployee recruit iEmpPK:I iEmpStatFK:I iEmpRaceFK:I iRefByFK:I lEmpBonus:L iEmpClasFK:I iEmpRecrFK:I cEmpCode:C(8) cEmpNum er:C(!") cEmpFirst:C(#") cEmp$idIni:C(!) cEmpLast:C(#%) cEmp&ddr!:C('") cEmp&ddr#:C('") cEmpCity:C(!() cEmpState:C(#) cEmp)ip:C(!") cEmp*+n&C:C(') cEmp*+one:C(8) cEmp*+nE.t:C(-) cCntFa. the out$ro&th of that s'stem &as chartin$ the financial course for a >. EDIT .K:L mEmpNotes:$ cEmp*+oto:C(/") cEmpResume:C(/") dEmpResRec:0 dEmpInter1:0 cEmp2ender:C(!) cEmpS3ills:C(!) cEmp&tt:C(!) cEmp*res:C(!) cEmpSSN:C(!!) dEmp0.yste' II /ctober 10& 1111 2ook(ate iBookDtPK:I iBoo3in5FK:I dB0B30ate:0 lB0Boo3ed:L tB0&rri1e:4 tB0Lea1e:4 tB0&ctStrt:4 tB0&ctEnd:4 nB0Lunc+:N('7") are made up of Role iRolePK:I cRoleCode:C(!") cRole0esc:C('") lRoleInact:L describe "uch more information on data desi$n and normaliDation can #e found on the internet or a $ood introductor' text on data#ase desi$n( Reading and !riting data Interactive REPLACE. and then thro& a&a'.fEmp:I cClBillCnct:C(#%) iClIn1Le1l:I lClConsult:L iCl&5enFmt:I iCl&5enCnt:I nClComm:N(-7#) mClNotes:$ nClLast8o :N(/7") )l)r. FoxPro provides relational integrity to the data#ase. and &e can sa' that there is a one-to-many relationship #et&een the ta#lesE one order ma' have man' line items( )he t'pical relations areE one-to-man'E parent to man' children. stuffin$ ever'thin$ into one ta#le &ill ma+e the processin$ @ 'our &or+ @ easier( /ut #e carefulJ I once created a set of la#els to invite some customers to a $olf tournament( Five 'ears later. of course( If 'ou are creatin$ a =uic+ and dirt' set of data to use for a &ee+. the order num#er is stored in #oth ta#les.B:0 nCntIn1Lim:N(!"7#) (ept iDeptPK:I iClientFK:I iContactFK:I c0ptCode:C(!") c0ptName:C(/") c0pt&ddr!:C(#") c0pt&ddr#:C(#") c0ptCity:C(#") c0ptState:C(#) c0pt)ip:C(!") c0pt&C:C(') c0pt*+one:C(8) c0pt*+nE.t:C(-) Receives agenda for Receives nvoices for s the primary contact for is referred by supervises is billed for Calls in Calls to create Supervises can belong to The .. an order ma' have a series of line items9.tat describes iCliStatPK:I cCSCode:C(!") cCS0esc:C(#%) lCSInact:L describes .tat describes iJobStatPK:I c8o StCode:C(!") c8o St0esc:C(#%) l8o StInac:L defines Generates E'p4%ail iEmpAvPK:I iEmpFK:I dE&0ate:0 lE&&1ail:L 3ob(uty consists of iJobDutyPK:I i0utyFK:I i8o FK:I n80*ercent:N('7") (uty describe iDutyPK:I c0utyCode:C(!") c0uty0esc:C('") l0utyInact:L have 2ookin$ iBookingPK:I iEmpFK:I i8o FK:I iCIBFK:I iSuper1FK:I dB36ee3End:0 cB30esc:C(8") lB3SpcSc+d:L tB3Start:4 tB3End:4 lB3Return:L mB3Notes:$ nB3BillRate:N(-7#) nB3*ayRate:N(-7#) lSunRate:L cB3C+30ist:C(!) iB3C+3No:I dE.B:0 lEmp$edEl:L lEmp$edCo1:L lEmpCautn:L mEmp&1ail:$ cEmp&14erm:C(!) dEmp&1Strt:0 dEmp&1End:0 dEmpLstSp3:0 E'pIndus have iEmpIndPK:I iEmpFK:I iIndustFK:I Industry describes iIndustPK:I cIndCode:C(!") cInd0esc:C('") lIndInact:L Describes E'pRace iEmpRacePK:I cERCode:C(!") cER0esc:C(#") lERInact:L E'p.t:C(-) c8o 0ept:C(/") c8o RptLoc:C(8") m8o Notes:$ c8o 6r3Ld:C(!) n8o *ct*er:N('7") n8o :rs63:N(%7#) c8o 0esc:C(/") c8o RptCmt:C(8") l8o In1Sep:L t8o $odify:4 c8o 9ser:C(!") E'p)lass iEmpClasPK:I cECCode:C(!") cEC0esc:C('") lECInact:L 3ob. throu$h the use of tri$$ers 6code automaticall' fired &hen a data chan$e ta+es place9 and stored procedures 6code stored &ithin the data#ase container9 to enforce the relationships defined on the data( qualify for Receive )l)o''is iClCommPK:I iEmpFK:I iClientFK:I nClComm*ct:N(-7#) )lient iClientPK:I iIndustFK:I iCliStatFK:I iClCrStaFK:I iCliEn1iFK:I iContactFK:I iBill4oFK:I i&5endaFK:I cClCode:C(!") cCode:C(%) cClName:C('") cCl&ddr!:C(#%) cCl&ddr#:C(#%) cCl&ddr':C(#%) cClCrossSt:C(#%) cClCity:C(!8) cClState:C(#) cCl)ip:C(!") cCl*+one&C:C(') cCl*+one:C(!") cCl*+nE.t:C(-) cEmpCell&C:C(') cEmpCell*+:C(8) cEmpBeep&C:C(') cEmpBeeper:C(8) cEmpEmail:C(%") lEmp*erm. su#tract or modif' data in all of the ta#les &ithout re$ard for the desi$n( For that reason. such as an order to order item Dero-or-one-to man'E a loo+up ta#le ma' #e referenced in none.-person compan'( )he rules for splittin$ up items #et&een ta#les are called normalization( 0ach ta#le 6also called an entity9 contains all of the attri#utes 6fields9 for one item( If an entit' can have more than a =uantit' of one attri#ute 6for example.&C:C(') cClFa.)he ans&er is nearl' al&a's the latter @ use multiple ta#les to separate different items( )here are exceptions.kill describe iSkillPK:I cS3illCode:C(!") cS3ill0esc:C(/") lS3illInac:L 3ob.No:C(!') cCl6e Site:C(/") cClEmail:C(/") cClContact:C(#%) cClCnt4itl:C(#%) tClStart:4 tClEnd:4 iClNo. BROWSE.kill iEmpSkilPK:I have iEmpFK:I iS3illFK:I cES3lLe1el:C(!) iES3lScore:I cES3l0esc:C('") mES3lNotes:$ )li.

&here all are completed or all are rolled #ac+ as a unit( . it can result in unaccepta#l' slo& performance in a WAN situation( )here are numerous other. either. &hen the amount of time to PA L or *0IN50A a VFP ta#le exceeds the recover' time of a client server s'stem follo&in$ a crash( As more operations move to&ards . and the political necessities of some environments( The 4)I( test 6 4to'icity& )onsistency& Isolation& (urability "an' or$aniDations 8ustif' their need for a client-server architecture &ith the A I5 test( A &ell-desi$ned client server s'stem meets all of the follo&in$ criteriaE Atomicit'E all data chan$es &ithin a transaction are treated as a sin$le indivisi#le unit. this factor has #ecome increasin$l' important( High-security informationE While it is possi#le to crac+ a client-server data#ase. APPEND. perhaps #ecause a chan$e involves multiple ta#les and the chan$es are not 'et complete. or #ecause one of a set of chan$es failed to update properl'( 0nter #ufferin$ and transactions( /ufferin$ allo&s data to #e stored on the local machine until all chan$es are read' to #e made at once( )his prevents t'in$ up shared data resources until the last possi#le minute. and allo&s the entire set of updates 61a sin$le transaction29 to either #e completed successfull' or rolled #ac+ completel'( Visual FoxPro provides support #oth for local 65/F-#ased9 transaction processin$ and for transaction processin$ in a client-server arran$ement( Client server data Why client*ser%er5 )here are three practical reasons to move a 5/F-#ased application to a client-server architectureE Too much dataE VFP has a ph'sical limit of . COP .BxG. includin$ the need for flexi#ilit' in distri#utin$ processin$. DELETE Transactions and buffering )here are some times in a relationship &hen 'ou are not read' to commit( )here are times &hen chan$es to a relational data#ase should not #e committed. DELETE S!L Commands INSERT. once 'ou are read' to commit the data( A transaction loc+s data records as the chan$es are committed.VFP Commands REPLACE. and allo&s local processin$ to examine old and ne& values of data 6each stored in a separate #uffer9 to determine ho& a chan$e should #e handled( )ransactions are the other end of the process. #ut the limit can often #e hit earlier.K# for a sin$le ta#le or memo file. "PDATE. and it ta+es advant$e of the lar$e #and&idth to locall' cache file headers. the li+elihood is far $reater in a VFP s'stem &here clients must have access to the underl'in$ ta#les Low bandwidthE VFP &as desi$ned to thrive in a net&or+ environment. more pra$matic reasons to move to a client-server architecture. indexes and records( While this results in remar+a#le *ushmore performance on a LAN.

IN%0*). 50L0)0. ontainersC Krids. APP0N5. 0dit/ox. the second transaction should fail( 5ura#ilit'E once the data has #een committed. 5!. L! L. IF. /*!W%0. Pa$eFrames. %ML commandsE %0L0 ). )ext/ox. LLFF. :P5A)0 !utputE ? *0P!*) F!*". %trin$ functions A%0 Controls )ext-#ased controlsE La#el. List/ox hec+/oxes ommand/uttonKroups ommand/uttons. AL :LA)0. N O%A?. %pinner Pic+-list controlsE /uttonsE om#o/ox. . *0PLA 0. LI%)I5I%PLA? )ext "anipulationE )extmer$e.onsistenc'E the inte$rit' rules for the data#ase are enforced at all times. it &ill #e stored and retrieved even if the s'stem suffers the loss of a hard dis+ or a processor or an' other component that doesn’t destro' the s'stem( )ransactions cannot #e 1lost(2 Part 2 6 It+s the codin$ "#$% commands& functions& ob'ect& $()s and design surfaces A/A%0 commandsE :%0. and one transaction’s intermediate results should not affect another transaction( If one transaction causes the initial conditions of a second transactions to fail. !ption/uttonsKroups. so that the data#ase is al&a's in a consistent and valid state( IsolationE results of a transaction are invisi#le until the' are complete.

in their simplest form. one exception #ein$ the class properties. Font%iDe. and the a#ilit' to define the code &hich should run &hen an event happens( 0vents are also much more numerous.Kraphical elementsE Ima$es. Left. $ivin$ us the chance to create interfaces more responsive to the user( )he controls supplied &ith Visual FoxPro are the startin$ point( )hese controls can 6and shouldJ9 #e su#classed to create our o&n custom controls( "ultiple controls ma' #e com#ined to form complex controls. if a visual control Pro#a#l' the sin$le most important propert'C letQs 'ou fi$ure out &hat 'ou &ere doin$ &hen 'ou return to it )he pedi$ree of the control 7o& the control is named #' all code &ithin the form &hich refers to it Whether the control should appear /ehavior durin$ mouse dra$ operations ?our hoo+ from the control into 'our custom help file For all text-#ased controls /ase lass. are simpl' the ne& versions of %A?s and K0)s( /ut controls are so much moreJ )he' offer much finer control of the individual o#8ects properties. lassLi#rar' Name Visi#le 5ra$"ode. lass. the a#ilit' to chan$e these properties at run-time. 5ra$Icon 7elp ontextI5 FontName. #etter reflectin$ the complexit' and #usiness rules of the particular application( ustom controls can #e created. saved and reused( $roperties Properties descri#e a characteristic of a control( "ost are availa#le #oth at desi$n and run-time. Font:nderline . 7ei$ht. %eparators 6tool#ars onl'9 !L0E #oth !L0/ound 6associated &ith data9 and Invisi#le controlE timer ontainer 6! A9 controls *orking !ith controls ontrols. Font%tri+ethrou$h. Lines. %hapes. Width omment Purpose )he location on the form of the o#8ect. &hich are read-onl' &hen the control is created( )hese properties are the data of the control &hich is PencapsulatedP &ith the control( "ost controls share a num#er of common propertiesE )o''on Property )op. Font/old. Font!utline. FontItalic.

*i$ht lic+. LostFocus When. 5#l lic+. /order olor. 5isa#ledFore olor.olor%cheme. 5ra$!ver Purpose ode run once &hen the control is created ode run &hen the control is released 7o& to #ehave &hen a dra$$ed o#8ect is over and dropped "ouse movement over a control /oth mouse #uttonsJ 7o& errors are handled ode &hen control is ta##ed to or clic+ed on !ur old friends( "ouse"ove lic+. /ac+ olor. "ouse:p 0rror KotFocus. 5isa#led/ac+ olor olors( )hen. "ouse5o&n. %pinner7i$hValue. Valid 7ethods "ethods tend to #e more individual to the controls. olor%ource. or pro$rammaticall' &hen a control chan$es status( It is not possi#le to define ne& events( ommon events includeE E%ent Init 5estro' 5ra$5rop. there are properties specific to an individual control or t&oE IntervalE ho& often a )imer control fires. as the' descri#e the uni=ue #ehavior of the control( )he most common areE 7ethod 5ra$ "ove %etFocus *efresh Purpose What to do if control is dra$$ed "oves controls &ithin a container Pro$rammaticall' PsendP focus to a control 0ach time the control needs . %pinnerLo&Value. Fore olor. and a sle& of othersJ E%ents 0vents occur &hen the user has ta+en some action.

$ive us access to the various pro$ramma#le and fixed properties.to #e redispla'ed. simplif'in$ the construction of o#8ects( Propert' sheets are tools that let us clim# under the hood and t&ea+ all the levers and dials( /uilders donQt have that depth. li+e our demo pro$ram. events and methods( /uilders $ive an alternative vie& into a limited num#er of properties. the code runs( Individual methods include the *eset method for the )imer control. either( A Typical Builder . #ut donQt have the complexit'. and the 5oVer# methods for the t&o !L0 controls( 7anipulatin$ controls: Property .heet 8 2uilders Propert' sheets.

clean event model &as introduced that allo&s a much simpler and more comprehensi#le approach to providin$ a trul' event-driven s'stem( . hi$hli$htin$ it.three or four levels is a#out all 'ouQll comprehend( (vent model In 'ears past. then selectin$ Q%ave as class(((P from the PFileP menu( "ost of the literature on the su#8ect of !!P states that it is a learnin$ process. #e&are of the pro#lem of over-en$ineerin$ a solution( 5onQt #e afraid to thro& out 'our &or+( 5onQt su#class it to death . rather than the standard tool#ar. protot'pe 'our first development in Visual FoxPro on a s'stem 'ou can thro& a&a'( In su#se=uent s'stems. &hen code started at the top of a procedure and executed line-#'-line until it &as done( "essa$e loops and 1Ketless *0A5s2 could #e used to simulate an event-driven s'stem. FoxPro &as #ased on a procedural model. a ne&. #ut there &as a tric+' series of o#scure #ehaviors to $et it to &or+( With the advent of Visual FoxPro. as the #asis for protot'pin$ screens( reate a custom control #' placin$ a control on a form. and a different &a' of loo+in$ at pro#lems( Anticipate that 'our first solution ma' not al&a's #e the #est one( If possi#le.A Pro#ert$ S%eet )reatin$ your o!n custo' controls ?ou &ill &ant to create 'our o&n set of custom controls so that 'ou can manipulate the #ase classes and modif' their properties and #ehaviors( It is a $ood idea to create a set of Q$enericQ #ut su#classed controls and use these.

4imer Column7.plus.of. $.Ctrl-&lt-S+ift.occurs.LEBoundControl Not. a menu can #e hoisted to the top of the screen.mo1ements.t+e.plus. and *0A5 0V0N)% &ill hold the entire application to$ether until the user chooses to =uit( )ime &ill tell if this model proves ro#ust enou$h for commercial applications( %o &hat are the ne& events? E%ent INI4 4pplies to: &ll. as &ith timers(P + #o. ut.ption2roup & o1e7.LEControl7.t+e.created7.line.t+e.middle.ERR.R> Code.$ro -elp #ile E%ent irin$ se9uences Pro#a#l' some of the most difficult functionalit' to understand( )'picall'.:eader7. or #' the s'stem.returns. .@ 0R&2.status. reco$niDed #' an o#8ect.drop.runs.dra55ed..is.include.o =ects.mouse.parameters>.and.Cursor7. #' pro$ram code.o =ect. efore.is.must.N.&lso.respecti1ely.an.R 0ES4R. *a5e7.met+od.an.=ust. left7. and destro'ed in the opposite fashion.a o1e What it does . o#8ects are created from the inside outE text#ox@Rcolumn@R$rid@Rpa$e@Rpa$eframe.order.fire.9SE0. !hat to put there Fires.$.Column7.durin5.<+en.error. implodin$( :o! to pro$ra' or e%ents5 )he Foundation read is no more. efore.Fires.and.Column7.6N7. accepts.If.ri5+t.fire.9SE$.added> Fires. ot+er<ise.an.optionally.o =ect.Relation7.upon.<+en.Contained. parameters. efore.reference.not. 0R&20R.What are E%ents5 PAn action. of.an. ut.dra5.statement.Separator Same & o1e7.Code.in. o =ect.o1er. a container cannot perform its action until its contents exist.?7.to. for &hich 'ou can &rite code to respond( 0vents can #e $enerated #' a user action.o =ect.o =ect>.<ell. Command2roup.is.same.9SE9* .and.statuses> $ouse. Containers.met+od. Custom7.coordinates> 4rac3s.to.of.name. FormSet7..a.mouse. such as clic+in$ the mouse or pressin$ a +e'. passes. containers7. from the outside in.AER7.-.AE CLICK7.completion. except for le$ac' code &e attempt to mi$rate to Visual FoxPro( Forms are it( )he concept #ehind Visual FoxPro is that the initial application environment can #e set up. o =ect. num er>.>F>7.accept.in.to.and. created>. therefore. utton.* $.it.clic3 ERR.and. a o1e7.contents> Fires.plus.error.as.mouse. .as.as. 0ataEn1ironment7.operation>.B.t+e.3eys7.released>.not. efore.passes.

is. .resiDed> .clic3ed.tBo.c+an5e.7.LEBoundControl7.R$ESS&2E $ESS&2E KE@*RESS C+ec3Bo.messa5e>.Form7. CommandButton7.<+en.<aitin5.ListBo.input.mouse.Line7.Spinner7.A&LI0.C9S7.ta ed.4.<+en. efore.made> 6+en.and.N.2rid7.Com oBo.7.t+e.LEControl7. EditBo.<+en. . :eader7. ut.LEControl7.focus). CommandButton7.to.of. EditBo.7.o =ect.tBo.an. ecause.of. een. CommandButton7.S+ape7.1isi le.LEControl7. compati ilityC 0isplays.for.7..Control7.7. & o1e7.7. CommandButton7. similar.t. acti1ation.status. 4e.2rid7.fire. Command2roup7. .StatusBar4e.7.+as. Command2roup7.Com oBo.ListBo.capa ilities> &llo<s.Control7.6:EN. Container7.7.a.ptionButton7.t>. .Form7.9IEN&BLE RI2:4CLICK 2. Column7.for. same. .&not+er. .*a5eFrame> Ri5+t.ption2roup7.7.as.A&LI07.ccurs.t+e.a.ptionButton7.6:EN ERR.4ool ar same.LEControl C+ec3Bo.control.>F>7. Fires.Com oBo. EditBo.of.Com oBo. Spinner7. completed> Fires.<+en.and.ptionButton7.t+an. ac3<ard.7.o =ect.Container7.tBo. CommandButton7. .rat+er.LEBoundControl7.to7. EditBo.7.2rid7. . *a5eFrame7.7.allo<s. .old.plus.c+an5e.7.recei1in5.ptionButton7.pro1ides. error. ar.C9S A&LI07.ption2roup7.mo1ed> $.of.*roperty.clic3.7.Spinner7.Spinner7. 4e. on> 2ood.LEBoundControl7.7.on.7.input.suc+.Ima5e7.4e. acceptin5. ecomes. after.y3eystro3e7.or. .tBo.AE0 RESI)E Fires. een. 4e.3eystro3e. L.ListBo. ac3<ard. . *a5eFrame7.ListBo..7.Form7. Container7. Control7. 4e.C.4F. .Form7. .tBo.(after.Spinner7. Command2roup7.as. .S4F.LEBoundControl7.CIncluded.processin5. La el7.+as. EditBo.t+e.a o1e C+ec3Bo.7.container7. .ption2roup7.is.a.te.7.control.control> .7.returns. C+ec3Bo. . C+ec3Bo. compati ility>C.Com oBo.ptionButton7.ption2roup7. e.display. ListBo.

<ill. made..&0 *&IN4 BEF.after.last.<+ile.do<n-.t+e.time.and.selected.element.ccurs. ut. &C4IA&4E7.t+e.control>. ein5. RE&0S:. Form7.a.control.run.9nLoad.En1ironment 4ool ar 2rid 2rid 2rid Com oBo.from. such as %pinners.2R&$$&4IC.<+ic+.is.cell.focus..re-paints>.a. c+an5es. ars.e1ent.CK7.occurF 6rappers.modes What to do no!5 0xperiment( 4.is.after.*R.or.c+an5e.*EN4&BLES7.Inter1al.List o.do<n.tBo.return.En1ironment>.also.N:.t+e. #ut either 6thou$h not necessaril' #othJ9 &or+( Add ne& 0vents to 'our arsenal as the .eac+.donEt.ScreenEs. . detects.+a1e. &fterRo<ColC+an5e 0ELE4E0 SCR. ein5.t+e. 0E&C4IA&4E R&N2E:I2:7.6+en.<it+. RE&0A&LI07.ListBo.lost> Not.code> Similar.interacti1e.mouse.t+e.6N7.of.acts. ut.or.for.0.3ey oard7. 4e. Spinner7.C&94I.7. efore.9NL.is.pro5rammatically> Similar. o.es.S+o<().or.or.6 0.after.&cti1ate.6NCLICK L.a.+as.in.Interacti1eC+an5e7.Fires..s+o<.arro<.t+e.a.t+e.ena led. a.CK7 BeforeRo<ColC+an5e7.parameter.IN4ER&C4IAE.mo1ement7.item.a.7.7.or.cursor. cell.or.t+e.runs.or.ro<.RE.and.CK7.fire> 6+en.&0 RE&0&C4IA&4E7.of.a.contents.9SE0. R&N2EL. control.may.performed. <+en..t+e.o =ects.as.<+en.Spinner7.<+ic+.one> Fires. close. ein5. 0ata.#>.of.mo1ed. passed> &llo<s. have finer control( lic+ is a more intuitive place to put #utton-firin$ code than VALI5. Spinner Form7. pressed> Load.For.LLE0 0R.is.Release4ype..ro<. ECompati ilityE. 4e.user. 4ool ar Com oBo.t+e.user.7. RE&06:EN Com oBo.series. met+od.5ets.&07.form. RESI)E.FormSet7.focus.RE0.met+ods> Code.is.returnin5.property.finer.only.4ool ar 0ata.confused.focus>.released. 2otFocus>. e.allo<. efore. Command2roup7. <+en.$. numeric.to. c+an5es.and.and.column.tool ar> Before. returns.7. *ro5rammaticC+an5e C+ec3Bo.is.met+od.Com oBo.a.after.SE4&BLES &F4ER0.t+e.Com oBo. EditBo.to. 4imer Form Form 6+at. efore.7.refres+().testin5.in.3eys.t+e.left7. runs>.Aalid.B.list> Fires. determine.or.FormSet Form7.ccurs.e1en.functions>.t+e.user.67..to.tBo.s+ifted.to.to. RE&00E&C4IA&4E7.t+e.t+e.model7.Close4a les().around. een7. y.if.9*0&4E0().<+en.of.t+e.ListBo. &F4ERCL.container.t+e.t+e.6NCLICK7.ListBo.For.Init7. BEF.to.*&IN4.scroll.7.usin5.R&N2E.4imer.manipulatin5.c+an5es7.S of the time the standard W70N and VALI5 &ill provide all the functionalit' needed in data entr' fields( %pecialiDed input fields.can.occurs.#>. Ccascadin5C.and.4ool ar>:ide()..automatic. 0ual.<or3s.initially.al<ays.4e.at.unmar3s.fires.7.0E&C4IA&4E.<+et+er.le1el>.clause>.deletion> 9ser.7.6N 4I$ER G9ER@9NL.tBo.Spinners.is.to.<+en.focus.or.s+ould.*0. 9N0.ption2roup7.RE&0.t+e.of.to.1ia.t+e. e+a1ior.to> 6+en.up-<ard-pointin5.pen4a les().mar3s.t+e.7. +as.*a5e7.5ets.test7.<it+in.and.drop.

bout the . online communities. a consultin$ firm #ased in Ne& 7ampshire( 7e is author of Essential SourceSafe. LL . ma$aDines T ne&sletters %harpen the sa& @ #oo+s and conferences )op )en "ista+es . the Fox Wi+i. %'stems 0n$ineer and seventime "icrosoft %upport "ost Valua#le Professional( ontact )ed at tedrocheNtedroche(com Ted Roche References "' 3<-'ear immersion in Fox soft&are and the other d/A%0 variants &ould have #een a much shallo&er and &ea+er experience had it not #een for the thrivin$ online communities @ ompu%erve. )ed is a "icrosoft ! LL" ertified %olution 5eveloper. the ProFox mailin$ list @ that have #rou$ht depth and meanin$ and humanit' to the experience( )han+s to all of those &ho participated( If 'ou are not 'et involved in an online communit'. at the .need arises( Anticipate some $reat third part' tools that +no& ho& to reall' ta+e advanta$e of all the ne& features( The tools      Pro8ect "ana$ers ode 0ditor Form 5esi$ner lass 5esi$ner "enu 5esi$ner Part III: 4d%anced topics !#8ect oriented anal'sis and desi$n !" and n-tier desi$n :ser Interface 5esi$n Pro8ect "ana$ement Part IV: Puttin$ it all to$ether *)F" @ VFP comes &ith an excellent set of resources( /ro&se the help file( )here is a tremendous amount of &ell-or$aniDed material there( 5on’t fi$ht the tide( Learn to #ecome one &ith the Fox #' thin+in$ the &a' the Fox thin+s( Ket a frame&or+ Ket a support $roupE mailin$ lists. and a contri#utor to < other FoxPro #oo+s( A former ontri#utin$ Associates 0ditor for FoxPro Advisor ma$aDine.uthor )ed *oche is president of )ed *oche T Associates. co-author &ith )amar Kranor of the Ted Roche a&ard-&innin$ Hacker's Guide to Visual FoxPro 6. find one and.

and the Virtual FoxPro :ser Kroup is online at httpEII&&&(vfu$(or$I( 2ooks I’m a #i$ advocate of learnin$ #' readin$( )here are a lot of fascinatin$ #oo+s out there. if not all. edit and enhance the existin$ &e# site( /ut there are a num#er of other &orth&hile sites( *od Paddoc+ hosts httpEII&&&(foxforum(com ( 0d Leafe hosts the ProFox mailin$ listC 'ou can si$n up at httpEII&&&(leafe(com. and I am al&a's in the process of readin$ a fe& at a time( If this isn’t 'our st'le. and store a&a' +no&led$e that there are other articles 'ou can $et #ac+ to later( Fox)al+ 6httpEII&&&(pinnaclepu#lishin$(comIft9 and FoxPro Advisor 6httpEII&&&(advisor(comI&&&IFoxProAdvisor9 are the leadin$ ma$aDines in the field( =ser -roups A user $roup t'picall' meets one evenin$ a &ee+ to s&ap stories. httpEII&&&(#ostonuser$roups(com. find ne& 8o#s. ompu%erve has opened their forums to the &e#( %tart at httpEII&&&(compuserve(com. 'ou &ill find most.a remar+a#le. and +eep up &ith &hat is $oin$ on in the industr'( )here are lists of user $roups at httpEIIfox(&i+is(comI&c(dll? Wi+iV ate$or':serKroups. or hit 'our favorite search en$ine to locate a $roup near 'ou? No $roups near#'? %tart 'our o&nJ . and $o from there( A direct lin+ that &or+s for me is httpEII$o(compuserve(comI"%5evApps?locUus .loo+ for 1#oo+shelf(2 Whil 7entDen maintains another list at httpEII&&&(hentDen&er+e(com his is called 1)he %tac+s(2 /et&een those t&o lists alone. meet &ith people of similar interests. at a ver' reasona#le cost( /nline co''unities Nearl' the $randdadd' of them all. consider han$in$ around &ith people &ho are +eepin$ up &ith the latest #oo+s @ #' visitin$ their &e# sites. li+e pro$rammin$. &ith man' &ell-+no&n authors and spea+ers fre=uentin$ the site( A close runner-up is the repositor' of +no&led$e #uilt up #' its mem#ers at httpEIIfox(&i+is(com . or this 1life2 thin$ I +eep hearin$ a#out( "' advice is to su#scri#e to all the ma$aDines that interest 'ou and at least s+im the ta#le of contents( )hat &a'. of the #oo+s I &ould recommend as &ell( 7a$a<ines FoxPro devotees should +eep up on &hat’s happenin$ in the FoxPro &orld #' readin$ ever'thin$ that’s availa#le out there( !f course. listenin$ to them at conferences and user $roup meetin$s. 'ou can read the articles that essential for 'ou to +no& ri$ht no&. locate consultants or consultin$ opportunities. lur+ in the #ac+$round for a &hile( )he support and education is invalua#le. net&or+. and support each other( )hese offer a $reat chance to $et out of the house. demonstrate some code or product. or &or+in$ &ith them( %teven /lac+ has an extensive readin$ list at httpEII&&&(steven#lac+(com . or$anic site that allo&s visitors to add.least.'our milea$e ma' var'( Pro#a#l' the most active FoxPro communit' on the &e# toda' is httpEII&&&(universalthread(com. or sleep. that &ould mean that there &ould #e no time left for other activities.

visit httpEIIcreativecommons(or$IlicensesI#'-nc-saI>(.. 34-F.is. Programmers at Work "icrosoft Press.. features a fascinatin$ intervie& &ith Wa'ne *atliff 6&hile he had an office at Ashton-)ate. :%A( . and the I/" A) &as considered a #ar$ain at HF..inks &n.planation.3-.&CI0.a1aila le.cellent.e.. 3G3 %econd %treet..#' )ed *oche( )his &or+ is licensed under the reative ommons Attri#ution-Noncommercial-%hare Ali+e >(.principles.on...9 dBASE is a re&istered trademar' o( dBASE Inc) Ot%er dBASE Inc) #rod*ct names are trademar's or re&istered trademar's o( dBASE Inc) !ri$inall' presented as a pre-conference session at the FoxPro 5ev . %an 5ie$o. %uite >. %eptem#er -..of.t+e. alifornia. & !ttp:""###$a sdigita$com"books"panda"databases%c!oosing && & Lammers. %an Francisco. A.... 4B3.. :nited %tates License( )o vie& a cop' of this license. .<..3.e.IusI or send a letter to reative ommons. %usan.3( op'ri$ht + ...