commands in foxpro

29
COMMANDS IN FOXPRO In foxpro first four characters of any command is enough to execute For e.g.:- crea ==> create TO OPEN THE DATABASE: Syn: use <dbname> Ex: use book TO CLOSE THE DATABASE: Use To close the current opened database. Close all To close the all opened database. TO Create New DATABASE: Syn: crea <dbname> create <dbname> Ex: crea book Modify Structure: Modify structure (Or) Modi stru

Upload: henry-earl-obias-siguenza

Post on 23-Nov-2015

354 views

Category:

Documents


35 download

DESCRIPTION

Sample Commands in Foxpro

TRANSCRIPT

COMMANDS IN FOXPROIn foxpro first four characters of any command is enough to executeFor e.g.:-crea==>createTO OPEN THE DATABASE: Syn: use Ex: use bookTO CLOSE THE DATABASE: Use To close the current opened database. Close all To close the all opened database.TO Create New DATABASE:Syn: crea create Ex: crea book

Modify Structure: Modify structure (Or) Modi struAPPENDAppend is used to add the new record.Syn: append [Blank] [From ]ExAppendAppend Blank- To add blank records.Append from first.dbf- To add the records from FIRST.DBF to SECOND.DBF- Same Structure is required for these databasesDISPLAYUsed to display the particular record.Syn: Display [All] [Structure] [Status] [Memory]Ex:DisplayDisplay AllDisplay All Records in page wise.To Display the structure of the databases:Display StructureTo display the status of the set commands.Display StatusTo display the status of the system memory variables.Display MemoryTo view the status barSet stat onTo edit the current RecordEdit GO TOPUsed to move the record pointer at the first record.GO BOTTOM:Used to move the record point at the last record.GoTo go to a particular recordSyn:- GO Eg:- GO 8Go to record 8ListUsed to list the records.Syn:list

Read more:http://www.livetolearn.in/site/programming/foxpro/basic-commands#ixzz2270YClSTPROGRAMA Program is a set of instructions used to achieve the desired output.To create new program or to edit the existing one.MODI COMMOR MODIFY COMMAND NOTEcommandIf ignore the particular line or command, NOTE can be used at the beginning of that line.Comment LineTo add comments to the right of the Programming code , use &&Clear All CommandThis command is used to closes all databases files and releases all active memory variables, arrays menus or popup.Input / Output command? | ?? | ??? [expr1?]?- To print the expression in new line??- To print the expression in the same line???- The Output will going to the printerExample:? "Hellow!"Sample ProgramNOTE prg for just print something on the screenClear&& To Clear the Screen or previous outputs?"Welcome"?"Hellow!"?? " World...!"??? "Thank youWriting Programs* FoxPro has powerful built-in editor for writingand editing.* It can be invoked from the command window byusing the MODIFY COMMAND.Syntax:MODIFY COMMAND Example:Modify Command journal(This program will automatically save with theextension .PRG)Press CTRL + W - To save and close the program windowExecuting ProgramPrograms can be executed by DO command.Syntax:DO Example:Do journalWhen compile the executed file the FoxPro creates an object code program with .FXP extension.If there are any errors, creates a file an .ERR extension.INPUT commandIt is used to accept Numeric input from the user and store it into a memory variable.Syntax:INPUT [] TO Example:Store 0 to enoINPUT"Enter your Enrollment No : " TO eno? EnoACCEPT commandIt is used to accept character input from the user and store it into a memory variable.Syntax:ACCEPT [] TO Example:Store space (15) toNAMACCEPT "Enter the Name: " toNAM? "Entered name:NAMExample 2clearSET TALK OFFAccept"Enter your nane :" to namInput "enter your Age: " to ageAccept " enter your city:" to citAccept "Enter your Mail id: " to mail? "******************************************"? "NAME::" ,nam? "AGE::" ,age? "CITY::" ,cit? "MAIL ID::" ,mail? "******************************************"Setting/restoring the environmentEvery FoxPro program includes all commands required to establish the working environment and restore it to its prior state before the program terminates execution. This is achieved by issuing some set.Set notify on/offEnables the display of certain system messages.Set talk windowDirectors the display of system messages to an user-defined window instead of the system window. Sets notify should be ON.Set deleted on/offProcesses records marked for deletion.

Read more:http://www.livetolearn.in/site/programming/foxpro/creating-program#ixzz22713QAKpInput and output in foxpro As we already know that data can be entered into tables through the APPEND/BROWSE commands. Data entry for tables can also be done through programs. There arises a need to display and accept information in a formatted way. The @say command is used to place data at a particular screen location and to display data stored in fields or memory variables. The @get commands is used to retrieve data.Displaying data@say command: -Syntax: -@SAY[Function][Picture][size=40 Then@10,10 say " You have PASS"EndifIf.else.endif:-The commands between if..end if will be executed only if condition is satisfied, otherwise the next statement is executed. For every if there must be an end if. Every is matched with the nearest unmatched if.Syntax:-If

Else

End ifCommand sequence 1 will be executed if a condition is true, if condition is false command sequence-2 will be executed. Control falls to the next statement in either case, if program I still in execution.Example 2clearStore 0 to x,y@5, 5 say " Enter the First value: " get x@7,5 say " Enter the Second value: " get yReadIF x > y Then@10, 10 say str(x) + is Greater than + ltrim (str(y))Else@10, 10 say str(x) + " is lesser than " + ltrim (str(y))EndifExample 3clearStore space(1) to x,ch@5, 5 say " Enter any Alphabet: " get xReadch =chr(asc(x) +32) && To convert Upper into LowerIF ch="a" .or. ch="e" .or. ch="i" .or. ch="o" .or. ch="u" then@10,10 say ch + " is a VOWEL "Else@10,10 say ch + " is a CONSONANT"EndifNESTED IF: (IF within IF)clearstore 0 to x,y,z@5,5 say " Enter No1 : " get x@7,5 say " Enter No2 : " get y@9,5 say " Enter No3 : " get zReadIf x > y thenIF x>z then@ 15,5 say " X is Greater than y and z"Else@15,5 say "X is Greater than Y and Lesser than Z"EndifElseIF Y>Z then@ 15,5 say " Y is Greater than X and Z"Else@15,5 say "Y is Greater than X but not Z"EndifEndifDO CASECase Commands are used to check for a specified conditionSyntax:DO CaseCase = Statement -1Case = Statement -2OtheriwseStatement -3End CaseExample:clearstore 0 to day@5,5 say " Enter any number from 1 to 7 " get dayRead DO CASE case day = 1 @10,10 say "SUNDAY" case day = 2 @10,10 say "MONDAY" case day = 3 @10,10 say "TUESDAY" case day = 4 @10,10 say "WEDNESDAY" case day = 5 @10,10 say "THURSDAY" case day = 6 @10,10 say "FRIDAY" case day = 7 @10,10 say "SATURDAY" OTHERWISE @10,10 SAy "Invalid Input"EndCaseFOR LOOP To repeatedly execute a series of lines in a Program. The lines of code b/w FOR and ENDOFR will be executed until the memory variable is equal to the final condition specified. Default STEP value is 1.SyntaxFOR = TO STEP ................................ENDFORExample: 1CLEARFOR I = 1 TO 10? IEndForExample: 2 To print the EVEN nos from 2 to 50CLEARFOR I = 2 TO 50 STEP 2? IEndFor

Read more:http://www.livetolearn.in/site/programming/foxpro/control-structures-foxpro#ixzz2271ZsZYd

This is an example of simple navigation menu programming inFoxpro2.61. set talk off2. set stat off3. set scor off4. set cent on5. set date brit6. do whil .t.7. clea8. @5,20 to 19,45 doub9. @6,25 say "MAIN MENU"10. @7,21 to 7,44 doub11. k=012. @ 9,25 prompt "DATA ENTRY"13. @11,25 prompt "REPORT PRINTING"14. @13,25 prompt "PROCESS"15. @15,25 prompt "EXIT"16. @17,25 prompt "QUIT to SYSTEM"17. menu to k18. do case19. case k=120. do dataent21. case k=222. do repoprn23. case k=324. * do proces25. case k=426. exit27. case k=528. clos all29. clea all30. quit31. otherwise32. loop33. endcase34. enddo 35. clos all36. clea all37. 38. 39. 40. proce dataent41. do whil .t.42. clea43. @5,20 to 19,55 doub44. @6,30 say "DATA ENTRY MENU"45. @7,21 to 7,5446. k1=047. @ 9,25 prompt "1. STUDENT"48. @11,25 prompt "2. STAFF"49. @13,25 prompt "3. FEES "50. @15,25 prompt "4. COURSES"51. @17,25 prompt "RETURN TO MAINMENU"52. menu to k153. do case 54. case k1=155. do stud56. case k1=257. do staff58. case k1=359. do fees60. case k1=461. do course62. case k1=563. exit 64. otherwise65. loop 66. endcase67. enddo 68. clos all 69. return70. 71. proce repoprn72. do whil .t.73. clea74. @5,20 to 19,55 doub75. @6,30 say "REPORT MENU"76. @7,21 to 7,5477. k1=078. @ 9,25 prompt "Report 1"79. @11,25 prompt "Report 2"80. @13,25 prompt "Report 3"81. @15,25 prompt "Report 4"82. @17,25 prompt "Return to Mainmenu"83. menu to k284. do case 85. case k2=186. do fmainprn87. case k2=288. do fothrprn89. case k2=390. do mainprn91. case k2=492. do othrprn93. case k2=594. exit 95. otherwise96. loop 97. endcase98. enddo 99. clos all 100. return

Read more:http://www.livetolearn.in/site/foxpro-programming/creating-menu-foxpro-dos#ixzz2272cUFyjSIMPLE JOURNAL ENTRY PROGRAMCLEAclea allset talk offuse jour1reply = "y"GO BOTTOMDO WHILE UPPER(REPLY) = "Y"STORE 0 TO CRE, DEBSTORE SPACE(10) TO P1, P2STORE SPACE(15) TO NRSTORE CTOD(" / / ") TO DATE1@4,10 SAY [DATE :] GET DATE1@6,10 SAY [PARTICULAR1 :] GET P1@6,45 SAY [DEBIT :] GET DEB@8,10 SAY [PARTICULAR2 :] GET P2@8,45 SAY [CREDIT :] GET CRE@12,10 SAY [NARRATION :] GET NRREADAPPEND BLANK@18,10 SAY [DO U CONTINUE(Y/N)?] GET REPLYREADREPL DATE WITH DATE1REPL PART1 WITH P1REPL PART2 WITH P2REPL NAR WITH NRREPL DEBIT WITH DEBREPL CREDIT WITH CREENDDOCLEARSET DEVI TO SCRESET PRINT ONSET PRIN TO RESUME1.OUT@2,30 SAY "JOURNAL ENTRIES"@3,0 SAY REPLICATE ("-",75)@4,5 SAY "DATE"@4,18 SAY "PARTICULARS"@4,48 SAY "DEBIT"@4,58 SAY "CREDIT"@5,0 SAY REPLICATE ("-",75)GO TOPROW = 6DO WHILE .NOT. EOF()@ROW,6 SAY DATE@ROW,19 SAY PART1 +[ DR]@ROW+1,19 SAY [TO ]+PART2@ROW+2,19 SAY [ (BEING ] +NAR+ [)]@ROW,45 SAY DEBIT@ROW+1, 55 SAY CREDITIF ROW >18WAIT ""@6,0 CLEARROW = 6ELSEROW = ROW + 3ENDIFSKIPENDDOSET DEVI TO SCRESET PRIN TOSET PRIN OFF

Read more:http://www.livetolearn.in/site/content/simple-journal-entry-program#ixzz2272ryAGySimple Ledger creation & Posting Programclearclea allset talk offuse jour1store space(15) to acnamestore 0 to r,p, ds, cs, br, bl, mamt@10,10 say "Account Name" get acnamereadclearset devi to screset print onset print to ledger.out@2,2 say replicate("-",75)@3,3 say "Date"@3,13 say "Particulars"@3,28 say "Amount"@3,41 say "Date"@3,52 say "Particulars"@3,67 say "Amount"@4,2 say replicate("-",75)@5,28 say [Ledger for ] + alltrim(acname)@6,28 say "-------------------"r = 7p = 7do while .not. eof()scan for upper(part1) = upper(alltrim(acname))@r,2 say date@r,11 say "To " + part2@r,26 say creditds = ds + creditr = r+1endscanscan for upper(part2) = upper(alltrim(acname))@p,40 say date@p,50 say "By " + part1@p,65 say debitcs = cs + debitp = p+1endscanenddoif p>rbr = pelsebr = rendifif cs > dsbl = cs - dsmamt = cs@r+1,11 say "To bal b/d"@r+1,26 say bl@br+5,50 say "By Bal c/d"@br+5,65 say blelsebl = ds - csmamt = ds@p+1, 50 say "By bal c/d"@p+1, 66 say bl@br+5,11 say "To Bal b/d"@br+5,26 say blendif@br+2,26 say "------------"@br+2,66 say "------------"@br+3,26 say mamt@br+3,66 say mamt@br+4,26 say "------------"@br+4,66 say "------------"@br+6,2 say replicate("-",75)set devi to screset print toset print offreturn

Read more:http://www.livetolearn.in/site/content/simple-ledger-creation-posting-program#ixzz227321AmITrial Balance Programclearclear allset talk offstore space(1) to reply@3,5 say "Do you continue?" get replyreaduse trial.dbfstore space(20) to pstore 0 to cr, db, snodo while upper(reply)="Y"clear@4,10 say [SlNo] get sno@6,10 say [Particular] get p@8,10 say [Debit] get db@10,10 say [Credit] get crreadappend blankrepl slno with snorepl part with prepl debit with dbrepl credit with cr@18,10 say [Do continue?] get replyreadclearenddoset print onset print to trial.out@2,30 say "Trial Balance"@3,2 say replicate("-",75)@4,2 say "S.No."@4,13 say "A/c Name"@4,28 say "Debit Rs"@4,42 say "Credit Rs"@5,1 say repl("-",75)store 0 to cs, ds, sus, ll = 6do while .not. eof()@l,2 say SLNO@l,7 say part@l,22 say debit@l,35 say creditif l >18wait ""@6,0 clearl = 6elsel = l + 1endifcs = cs + creditds = ds + debitskipenddoif cs > dssus = cs - ds@l,7 say "Suspense A/c"@l,22 say suselseif ds > cssus = ds - cscs = ds@l,7 say "Suspense A/c"@l,35 say susendifendif@l+1,21 say "---------------"@l+1,34 say "---------------"@l+3,21 say "---------------"@l+3,34 say "---------------"@l+2,22 say cs@l+2,35 say csset print offset print toreturn

Read more:http://www.livetolearn.in/site/content/trial-balance-program#ixzz2273C2eg5Balance Sheet Programcleaclear allset talk off@1,15 say "Trading A/c for the Year Ended"@2,2 say replicate("-",75)@3,7 say "Particulars"@3,45 say "Particulars"@4,2 say repl("-",75)store 0 to opst, pur, purret, tpur, tdeb, wage, wout, twage, carin@5,2 say "To Opening stock"@5,30 get opst@6,2 say "To purchase"@6,20 get pur@7,4 say "Purchase Ret."@7,20 get purretreadtpur = pur - purret@7,30 say tpur@8,2 say "To wages"@8,20 get wage@9,4 say "Out.wages"@9,20 get woutreadtwage = wage + wout@9,30 say twage@10,2 say "To carriage inwards"@10,30 get carinreadtdeb = opst + tpur + twage + carinstore 0 to sale, saleret, tsale, clstock, tcr@5,40 say "By Sales"@5,58 get sale@6,40 say "(-)Sales Return"@6,58 get saleretreadtsale = sale - saleret@6,68 say tsale@7,40 say "By Closing Stock:"@7,68 get clstockreadtcr = clstock + tsalestore 0 to grpro, grloss, gramtgrpro = tcr - tdebif grpro < 0grloss = abs(grpro)grpro = 0@11,40 say "By Gross Loss:"@11,68 say grlossgramt = tdebelse@11,2 say "To Gross Profit:"@11,30 say grprogramt = tcrendif@12,2 say repl("-",75)@13,30 say gramt@13,68 say gramt@14,2 say repl("-",75)wait""clear* Profit & Loss Account *@1,15 say "Profit & Loss A/c for the Year Ended"@2,2 say replicate("-",75)@3,7 say "Particulars"@3,45 say "Particulars"@4,2 say repl("-",75)if grloss = 0@5,40 say "By Gross Profit B/D"@5,68 say grproelse@5,2 say "To Gross Loss b/d"@5,30 say grlossendifstore 0 to sal, osal, tsal, rent, adv, pcr, pdb@6,2 say "To Salaries"@6,20 get sal@7,3 say "(+)Out.Salary"@7,20 get osalreadtsal = sal + osal@7,30 say tsal@8,2 say "To Rent"@8,30 get rent@9,2 say "To Advertise"@9,30 get advreadpdb = adv + rent + tsal + grlossstore 0 to dis, odb, ndb, debts, netpro, pamt, netloss@6,40 say "By Disc. Receiv"@6,68 get dis@7,40 say "By Old debts"@7,58 get odb@8,40 say "(-) New debts"@8,58 get ndbreaddebts = odb - ndb@8,68 say debtspcr = debts + dis + grpronetpro = pcr - pdbif netpro > 0pamt = pcr@10,2 say "To Net profit"@10,30 say netproelsenetloss = pdb - pcrpamt = pdb@10,42 say "To Net Loss:"@10,68 say netlossendif@11,2 say repl("-",75)@12,30 say pamt@12,68 say pamt@13,2 say repl("-",75)wait windowclear**Balance Sheet**store 0 to ass, land, cashb, cashh, rsrv, cap, aint@2,25 say "Balance sheet for the year Ended"@3,2 say repl("-",75)@4,3 say "Liablities Amount"@4,48 say "Assets Amount"@5,2 say repl("-",75)@6,2 say "Capital"@6,20 get cap@7,2 say "Add. Int"@7,20 get aintreadif netpro > 0@8,2 say "(+)Net pro"@8,20 say netprocap = cap + aint + netproelse@8,2 say "(-)Net Loss:"@8,20 say netlosscap = cap + aint - netlossendif@8,30 say cap@9,2 say "Reserve Fund"@9,30 get rsrvreadliab = rsrv + cap@6,48 say "Cash in Hand:"@6,68 get cashh@7,48 say "Cash at Bank:"@7,68 get cashb@8,48 say "Land:"@8,68 get landass = land + cashb + cashh@10,2 say repl("-",75)@11,30 say liab@11,68 say ass@12,2 say repl("-",75)wait windowreturn

Read more:http://www.livetolearn.in/site/content/balance-sheet-program#ixzz2273Ly5KC