buat agan-agan yang masih pakai foxpro under DOS atau biasa di bilang FOXPRO 2.6, berikut ini ane bagi dikit dari hari browsing kesana kemari bersama ayu ting-ting.. saya yakin pasti masih banyak anda yang mengunakan bahasa pemrograman ini terutama agan2 yang bekerja di lembaga keuangan coz perlu biaya yang mahal dan mengantisifasi kemungkinan kehilangan data saat pindah rumah jadi pake FOXPRO under DOS aja..begitu juga dengan kantor saya.. mari langsung NGODING aja gan
Create a program
PROGRAM
A Program is a set of instructions used to achieve the desired output.
A Program is a set of instructions used to achieve the desired output.
To create new program or to edit the
existing one.
MODI COMM
OR MODIFY COMMAND
NOTE command
If ignore the particular line or command, NOTE can be used at the beginning of that line.
Comment Line
To add comments to the right of the Programming code , use &&
Clear All Command
This 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 printer
Example:
? "Hellow!"
Sample Program
NOTE prg for just print something on the screen
Clear && To Clear the Screen or previous outputs
?"Welcome"
?"Hellow!"
?? " World...!"
??? "Thank you”
Writing Programs
* FoxPro has powerful built-in editor for writing and editing.
* It can be invoked from the command window by using the MODIFY COMMAND.
Syntax:
MODIFY COMMAND
Example:
Modify Command journal
(This program will automatically save with the extension .PRG)
Press CTRL + W - To save and close the program window
Executing Program
Programs can be executed by DO command.
Syntax:
DO
Example:
Do journal
When 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 command
It is used to accept Numeric input from the user and store it into a memory variable.
Syntax:
INPUT [] TO
Example:
Store 0 to eno
INPUT "Enter your Enrollment No : " TO eno
? Eno
ACCEPT command
It is used to accept character input from the user and store it into a memory variable.
Syntax:
ACCEPT [] TO
Example:
Store space (15) to NAM
ACCEPT "Enter the Name: " to NAM
? "Entered name:” NAM
Example 2
clear
SET TALK OFF
Accept "Enter your nane :" to nam
Input "enter your Age : " to age
Accept " enter your city :" to cit
Accept "Enter your Mail id : " to mail
? "******************************************"
? "NAME :: " ,nam
? "AGE :: " ,age
? "CITY :: " ,cit
? "MAIL ID:: " ,mail
? "******************************************"
Setting/restoring the environment
Every 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/off
Enables the display of certain system messages.
Set talk window
Directors the display of system messages to an user-defined window instead of the system window. Sets notify should be ON.
Set deleted on/off
Processes records marked for deletion.
MODI COMM
OR MODIFY COMMAND
NOTE command
If ignore the particular line or command, NOTE can be used at the beginning of that line.
Comment Line
To add comments to the right of the Programming code , use &&
Clear All Command
This 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 printer
Example:
? "Hellow!"
Sample Program
NOTE prg for just print something on the screen
Clear && To Clear the Screen or previous outputs
?"Welcome"
?"Hellow!"
?? " World...!"
??? "Thank you”
Writing Programs
* FoxPro has powerful built-in editor for writing and editing.
* It can be invoked from the command window by using the MODIFY COMMAND.
Syntax:
MODIFY COMMAND
Example:
Modify Command journal
(This program will automatically save with the extension .PRG)
Press CTRL + W - To save and close the program window
Executing Program
Programs can be executed by DO command.
Syntax:
DO
Example:
Do journal
When 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 command
It is used to accept Numeric input from the user and store it into a memory variable.
Syntax:
INPUT [
Example:
Store 0 to eno
INPUT "Enter your Enrollment No : " TO eno
? Eno
ACCEPT command
It is used to accept character input from the user and store it into a memory variable.
Syntax:
ACCEPT [
Example:
Store space (15) to NAM
ACCEPT "Enter the Name: " to NAM
? "Entered name:” NAM
Example 2
clear
SET TALK OFF
Accept "Enter your nane :" to nam
Input "enter your Age : " to age
Accept " enter your city :" to cit
Accept "Enter your Mail id : " to mail
? "******************************************"
? "NAME :: " ,nam
? "AGE :: " ,age
? "CITY :: " ,cit
? "MAIL ID:: " ,mail
? "******************************************"
Setting/restoring the environment
Every 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/off
Enables the display of certain system messages.
Set talk window
Directors the display of system messages to an user-defined window instead of the system window. Sets notify should be ON.
Set deleted on/off
Processes records marked for deletion.
Input and Output Statements in
Foxpro
Input 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]
[font[,
[STYLE, exprC4>]
Example:-
@2, 10 say “hello welcome to 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: -
@
[Function
[Picture
[size
[font
Example:-
@2, 10 say “hello welcome to FoxPro”
Syntax:
Input
@row,column | say get
Output
@row ,column | say get
Clear
@row, column to row, column clear
Clear all
Ex
@5, 5 clear to 20, 20
Input
@row,column | say
Output
@row ,column | say
Clear
@row, column to row, column clear
Clear all
Ex
@5, 5 clear to 20, 20
Box Command
@row1, column1 to row2, column 2
Picture clause
PICTURE clause is used to control of display or the information to be accepted.
@..SAY...GETS PICTURE CODES:
A - Allows only alphabets
9 - Allows only digits, signs for numeric data
N - Allows Letters and Digits
# - Allows Only Digits, Blanks and Signs
X - Allows any Character
L - Allows any Logical Data T, t, F, f, Y, y, N, n
Y - Allows Only Y, y, N, n
! - Converts letters into uppercase.
* - Displays asterisk in place of leading zeros.
, - Display the comma
. - Display the decimal Point.
Function Clause
You can include the function clause, the picture clause or both to control how is displayed or printed. A function clause affects the entire
expression. It contains only the following function code.
Function code & Purpose
B Left – justifies numeric data within the display region.
Example:
Clear
Store 2750 to num
@5,20 say num
@6,20 say num function “B”
C Cr is displayed after a positive number to indicate a credit. Can be used with numeric data only.
Example:-
Clear
Store 15432.00 to amt
@5,20 say amt
@6,20 say amt function “c”
D Uses the current set DATE format.
Example:-
Clear
Store 230801 to num
Store “foxproprograming” to tit
@5,20 say num function “D”
@6,20 say tit function “D”
E Edits date type data as British date
Example:-
Clear
Store 230904 to num
@6,20 say num function “E”
T Trim leading and trailing blanks from
Example:-
Clear
@5,20 ”fox” to tit
@6,20 say tit function “T”
X DB is displayed after negative numbers to indicate a debit. used only with numberic data.
Example:-
Clear
Store -15432.00 to amt
@5,20 say amt
@6,20 say amt function “X”
@row1, column1 to row2, column 2
Picture clause
PICTURE clause is used to control of display or the information to be accepted.
@..SAY...GETS PICTURE CODES:
A - Allows only alphabets
9 - Allows only digits, signs for numeric data
N - Allows Letters and Digits
# - Allows Only Digits, Blanks and Signs
X - Allows any Character
L - Allows any Logical Data T, t, F, f, Y, y, N, n
Y - Allows Only Y, y, N, n
! - Converts letters into uppercase.
* - Displays asterisk in place of leading zeros.
, - Display the comma
. - Display the decimal Point.
Function Clause
You can include the function clause, the picture clause or both to control how
Function code & Purpose
B Left – justifies numeric data within the display region.
Example:
Clear
Store 2750 to num
@5,20 say num
@6,20 say num function “B”
C Cr is displayed after a positive number to indicate a credit. Can be used with numeric data only.
Example:-
Clear
Store 15432.00 to amt
@5,20 say amt
@6,20 say amt function “c”
D Uses the current set DATE format.
Example:-
Clear
Store 230801 to num
Store “foxproprograming” to tit
@5,20 say num function “D”
@6,20 say tit function “D”
E Edits date type data as British date
Example:-
Clear
Store 230904 to num
@6,20 say num function “E”
T Trim leading and trailing blanks from
Example:-
Clear
@5,20 ”fox” to tit
@6,20 say tit function “T”
X DB is displayed after negative numbers to indicate a debit. used only with numberic data.
Example:-
Clear
Store -15432.00 to amt
@5,20 say amt
@6,20 say amt function “X”
Z
is displayed as all blanks if its numeric
value is 0. used only with numeric data.
Example:
Clear
Store o to amt
@5,20 say amt
@6,20 say amt function “z”
value is 0. used only with numeric data.
Example:
Clear
Store o to amt
@5,20 say amt
@6,20 say amt function “z”
( Encloses
negative numbers in parentheses. Used only with numeric data.
Example:-
Clear
Store –755 to amt
@5,20 say amt
@6,20 say amt function “(“
Example:-
Clear
Store –755 to amt
@5,20 say amt
@6,20 say amt function “(“
! Converts
alphabetic characters to upper-case used with character data-only
Example:-
Clear
Store “foxpro programming” to tit
@6,20 say tit function “!”
Example:-
Clear
Store “foxpro programming” to tit
@6,20 say tit function “!”
^ Displays
numeric data using scientific notation. Used with numeric data only.
Example:-
Clear
Store 75815 to amt
@6,20 say amt function “^”
Clear
Store 75815 to amt
@6,20 say amt function “^”
$
Displays data in currently format. the currency symbol appears before or after the field value depending on the current setting of set currency. used with numeric data only.
Example:-
Clear
Store 75815 to amt
@6,20 say amt function “$”
Picture expression can include the following characters:-
Displays data in currently format. the currency symbol appears before or after the field value depending on the current setting of set currency. used with numeric data only.
Example:-
Clear
Store 75815 to amt
@6,20 say amt function “$”
Picture expression can include the following characters:-
X Allows any character.
Y Allows logical Y, y, N and n only.
Converts y and n to Y and N, respectively.
! Displays the current currency symbol specified by set currency. By default, the symbol is placed immediately before or after the field.
* Asterisks are displayed in front of the numeric value. Use with a dollar sign $ for check protection.
. A decimal point specifies the decimal point position.
, A comma is used to specifies digits to the left of the decimal point.
! Displays the current currency symbol specified by set currency. By default, the symbol is placed immediately before or after the field.
* Asterisks are displayed in front of the numeric value. Use with a dollar sign $ for check protection.
. A decimal point specifies the decimal point position.
, A comma is used to specifies digits to the left of the decimal point.
Control Structures in Foxpro
Control Structures
IF statement
If Condition is True Executed and then False Not Executed.
Syntax
If (condition) then
Statement-1
End if
Example
clear
mark =0
@5,5 say " Enter the Mark : " get mark RANGE 0,100
Read
If mark >=40 Then
@10,10 say " You have PASS"
Endif
IF statement
If Condition is True Executed and then False Not Executed.
Syntax
If (condition) then
Statement-1
End if
Example
clear
mark =0
@5,5 say " Enter the Mark : " get mark RANGE 0,100
Read
If mark >=40 Then
@10,10 say " You have PASS"
Endif
If….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 if
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 if
Command 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 2
clear
Store 0 to x,y
@5, 5 say " Enter the First value: " get x
@7,5 say " Enter the Second value: " get y
Read
IF 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))
Endif
Example 3
clear
Store space(1) to x,ch
@5, 5 say " Enter any Alphabet: " get x
Read
ch =chr(asc(x) +32) && To convert Upper into Lower
IF 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"
Endif
clear
Store 0 to x,y
@5, 5 say " Enter the First value: " get x
@7,5 say " Enter the Second value: " get y
Read
IF 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))
Endif
Example 3
clear
Store space(1) to x,ch
@5, 5 say " Enter any Alphabet: " get x
Read
ch =chr(asc(x) +32) && To convert Upper into Lower
IF 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"
Endif
NESTED IF: (IF within IF)
clear
store 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 z
Read
If x > y then
IF 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"
Endif
Else
IF 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"
Endif
Endif
DO CASE
Case Commands are used to check for a specified condition
Syntax:
DO Case
Case =
Statement -1
Case =
Statement -2
Otheriwse
Statement -3
End Case
Example:
clear
store 0 to day
@5,5 say " Enter any number from 1 to 7 " get day
Read
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"
EndCase
FOR LOOP
clear
store 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 z
Read
If x > y then
IF 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"
Endif
Else
IF 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"
Endif
Endif
DO CASE
Case Commands are used to check for a specified condition
Syntax:
DO Case
Case
Statement -1
Case
Statement -2
Otheriwse
Statement -3
End Case
Example:
clear
store 0 to day
@5,5 say " Enter any number from 1 to 7 " get day
Read
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"
EndCase
FOR 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.
Syntax
FOR = TO STEP
................
................
ENDFOR
Example: 1
CLEAR
FOR I = 1 TO 10
? I
EndFor
Example: 2
To print the EVEN nos from 2 to 50
CLEAR
FOR I = 2 TO 50 STEP 2
? I
EndFor
FOR
................
................
ENDFOR
Example: 1
CLEAR
FOR I = 1 TO 10
? I
EndFor
Example: 2
To print the EVEN nos from 2 to 50
CLEAR
FOR I = 2 TO 50 STEP 2
? I
EndFor
Create menu in foxpro
1. set
talk off
2. set
stat off
3. set
scor off
4. set
cent on
5. set
date brit
6. do
whil .t.
7. clea
8. @5,20 to 19,45 doub
9. @6,25 say "MAIN MENU"
10. @7,21 to 7,44 doub
11. k=0
12. @ 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 k
18. do case
19. case k=1
20. do dataent
21. case k=2
22. do repoprn
23. case k=3
24.* do proces
25. case k=4
26. exit
27. case k=5
28. clos all
29. clea all
30. quit
31. otherwise
32. loop
33. endcase
34.enddo
35.clos all
36.clea all
37.
38.
39.
40.proce
dataent
41.do whil .t.
42. clea
43. @5,20 to 19,55 doub
44. @6,30 say "DATA ENTRY MENU"
45. @7,21 to 7,54
46. k1=0
47. @ 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 k1
53. do case
54. case k1=1
55. do stud
56. case k1=2
57. do staff
58. case k1=3
59. do fees
60. case k1=4
61. do course
62. case k1=5
63. exit
64. otherwise
65. loop
66. endcase
67.enddo
68.clos
all
69.return
70.
71.proce
repoprn
72.do whil
.t.
73. clea
74. @5,20 to 19,55 doub
75. @6,30 say "REPORT MENU"
76. @7,21 to 7,54
77. k1=0
78. @ 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 k2
84. do case
85. case k2=1
86. do fmainprn
87. case k2=2
88. do fothrprn
89. case k2=3
90. do mainprn
91. case k2=4
92. do othrprn
93. case k2=5
94. exit
95. otherwise
96. loop
97. endcase
98.enddo
99.clos
all
100. return
Journal Entry Program
CLEA
clea all
set talk off
use jour1
reply = "y"
GO BOTTOM
DO WHILE UPPER(REPLY) = "Y"
STORE 0 TO CRE, DEB
STORE SPACE(10) TO P1, P2
STORE SPACE(15) TO NR
STORE 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 NR
READ
APPEND BLANK
@18,10 SAY [DO U CONTINUE(Y/N)?] GET REPLY
READ
REPL DATE WITH DATE1
REPL PART1 WITH P1
REPL PART2 WITH P2
REPL NAR WITH NR
REPL DEBIT WITH DEB
REPL CREDIT WITH CRE
ENDDO
CLEAR
SET DEVI TO SCRE
SET PRINT ON
SET 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 TOP
clea all
set talk off
use jour1
reply = "y"
GO BOTTOM
DO WHILE UPPER(REPLY) = "Y"
STORE 0 TO CRE, DEB
STORE SPACE(10) TO P1, P2
STORE SPACE(15) TO NR
STORE 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 NR
READ
APPEND BLANK
@18,10 SAY [DO U CONTINUE(Y/N)?] GET REPLY
READ
REPL DATE WITH DATE1
REPL PART1 WITH P1
REPL PART2 WITH P2
REPL NAR WITH NR
REPL DEBIT WITH DEB
REPL CREDIT WITH CRE
ENDDO
CLEAR
SET DEVI TO SCRE
SET PRINT ON
SET 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 TOP
ROW = 6
DO 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 CREDIT
IF ROW >18
WAIT ""
@6,0 CLEAR
ROW = 6
ELSE
ROW = ROW + 3
ENDIF
SKIP
ENDDO
SET DEVI TO SCRE
SET PRIN TO
SET PRIN OFF
DO 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 CREDIT
IF ROW >18
WAIT ""
@6,0 CLEAR
ROW = 6
ELSE
ROW = ROW + 3
ENDIF
SKIP
ENDDO
SET DEVI TO SCRE
SET PRIN TO
SET PRIN OFF
Ledger creation & Posting Program
clear
clea all
set talk off
use jour1
store space(15) to acname
store 0 to r,p, ds, cs, br, bl, mamt
@10,10 say "Account Name" get acname
read
clear
set devi to scre
set print on
set 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 = 7
p = 7
do while .not. eof()
scan for upper(part1) = upper(alltrim(acname))
@r,2 say date
@r,11 say "To " + part2
@r,26 say credit
ds = ds + credit
r = r+1
endscan
scan for upper(part2) = upper(alltrim(acname))
@p,40 say date
@p,50 say "By " + part1
@p,65 say debit
cs = cs + debit
p = p+1
endscan
enddo
clea all
set talk off
use jour1
store space(15) to acname
store 0 to r,p, ds, cs, br, bl, mamt
@10,10 say "Account Name" get acname
read
clear
set devi to scre
set print on
set 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 = 7
p = 7
do while .not. eof()
scan for upper(part1) = upper(alltrim(acname))
@r,2 say date
@r,11 say "To " + part2
@r,26 say credit
ds = ds + credit
r = r+1
endscan
scan for upper(part2) = upper(alltrim(acname))
@p,40 say date
@p,50 say "By " + part1
@p,65 say debit
cs = cs + debit
p = p+1
endscan
enddo
if p>r
br = p
else
br = r
endif
br = p
else
br = r
endif
if cs > ds
bl = cs - ds
mamt = 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 bl
else
bl = ds - cs
mamt = 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 bl
endif
bl = cs - ds
mamt = 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 bl
else
bl = ds - cs
mamt = 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 bl
endif
@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 scre
set print to
set print off
return
@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 scre
set print to
set print off
return
Trial Balance Program
clear
clear all
set talk off
store space(1) to reply
@3,5 say "Do you continue?" get reply
read
use trial.dbf
store space(20) to p
store 0 to cr, db, sno
do 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 cr
read
append blank
repl slno with sno
repl part with p
repl debit with db
repl credit with cr
@18,10 say [Do continue?] get reply
read
clear
enddo
set print on
set 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)
clear all
set talk off
store space(1) to reply
@3,5 say "Do you continue?" get reply
read
use trial.dbf
store space(20) to p
store 0 to cr, db, sno
do 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 cr
read
append blank
repl slno with sno
repl part with p
repl debit with db
repl credit with cr
@18,10 say [Do continue?] get reply
read
clear
enddo
set print on
set 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, l
l = 6
do while .not. eof()
@l,2 say SLNO
@l,7 say part
@l,22 say debit
@l,35 say credit
if l >18
wait ""
@6,0 clear
l = 6
else
l = l + 1
endif
cs = cs + credit
ds = ds + debit
skip
enddo
if cs > ds
sus = cs - ds
@l,7 say "Suspense A/c"
@l,22 say sus
else
if ds > cs
sus = ds - cs
cs = ds
@l,7 say "Suspense A/c"
@l,35 say sus
endif
endif
l = 6
do while .not. eof()
@l,2 say SLNO
@l,7 say part
@l,22 say debit
@l,35 say credit
if l >18
wait ""
@6,0 clear
l = 6
else
l = l + 1
endif
cs = cs + credit
ds = ds + debit
skip
enddo
if cs > ds
sus = cs - ds
@l,7 say "Suspense A/c"
@l,22 say sus
else
if ds > cs
sus = ds - cs
cs = ds
@l,7 say "Suspense A/c"
@l,35 say sus
endif
endif
@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 cs
@l+1,34 say "---------------"
@l+3,21 say "---------------"
@l+3,34 say "---------------"
@l+2,22 say cs
@l+2,35 say cs
set print off
set print to
return
set print to
return
Balance Sheet Program
clea
clear all
set 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 purret
read
tpur = pur - purret
@7,30 say tpur
@8,2 say "To wages"
@8,20 get wage
@9,4 say "Out.wages"
@9,20 get wout
read
twage = wage + wout
@9,30 say twage
@10,2 say "To carriage inwards"
@10,30 get carin
read
tdeb = opst + tpur + twage + carin
clear all
set 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 purret
read
tpur = pur - purret
@7,30 say tpur
@8,2 say "To wages"
@8,20 get wage
@9,4 say "Out.wages"
@9,20 get wout
read
twage = wage + wout
@9,30 say twage
@10,2 say "To carriage inwards"
@10,30 get carin
read
tdeb = opst + tpur + twage + carin
store 0 to sale, saleret, tsale,
clstock, tcr
@5,40 say "By Sales"
@5,58 get sale
@6,40 say "(-)Sales Return"
@6,58 get saleret
read
tsale = sale - saleret
@6,68 say tsale
@7,40 say "By Closing Stock:"
@7,68 get clstock
read
tcr = clstock + tsale
@5,58 get sale
@6,40 say "(-)Sales Return"
@6,58 get saleret
read
tsale = sale - saleret
@6,68 say tsale
@7,40 say "By Closing Stock:"
@7,68 get clstock
read
tcr = clstock + tsale
store 0 to grpro, grloss, gramt
grpro = tcr - tdeb
if grpro < 0
grloss = abs(grpro)
grpro = 0
@11,40 say "By Gross Loss:"
@11,68 say grloss
gramt = tdeb
else
@11,2 say "To Gross Profit:"
@11,30 say grpro
gramt = tcr
endif
@12,2 say repl("-",75)
@13,30 say gramt
@13,68 say gramt
@14,2 say repl("-",75)
wait""
grpro = tcr - tdeb
if grpro < 0
grloss = abs(grpro)
grpro = 0
@11,40 say "By Gross Loss:"
@11,68 say grloss
gramt = tdeb
else
@11,2 say "To Gross Profit:"
@11,30 say grpro
gramt = tcr
endif
@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 grpro
else
@5,2 say "To Gross Loss b/d"
@5,30 say grloss
endif
store 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 osal
read
tsal = sal + osal
@7,30 say tsal
@8,2 say "To Rent"
@8,30 get rent
@9,2 say "To Advertise"
@9,30 get adv
read
pdb = adv + rent + tsal + grloss
store 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 ndb
read
debts = odb - ndb
@8,68 say debts
@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 grpro
else
@5,2 say "To Gross Loss b/d"
@5,30 say grloss
endif
store 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 osal
read
tsal = sal + osal
@7,30 say tsal
@8,2 say "To Rent"
@8,30 get rent
@9,2 say "To Advertise"
@9,30 get adv
read
pdb = adv + rent + tsal + grloss
store 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 ndb
read
debts = odb - ndb
@8,68 say debts
pcr = debts + dis + grpro
netpro = pcr - pdb
if netpro > 0
pamt = pcr
@10,2 say "To Net profit"
@10,30 say netpro
else
netloss = pdb - pcr
pamt = pdb
@10,42 say "To Net Loss:"
@10,68 say netloss
endif
@11,2 say repl("-",75)
@12,30 say pamt
@12,68 say pamt
@13,2 say repl("-",75)
wait window
clear
netpro = pcr - pdb
if netpro > 0
pamt = pcr
@10,2 say "To Net profit"
@10,30 say netpro
else
netloss = pdb - pcr
pamt = pdb
@10,42 say "To Net Loss:"
@10,68 say netloss
endif
@11,2 say repl("-",75)
@12,30 say pamt
@12,68 say pamt
@13,2 say repl("-",75)
wait window
clear
**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 aint
read
if netpro > 0
@8,2 say "(+)Net pro"
@8,20 say netpro
cap = cap + aint + netpro
else
@8,2 say "(-)Net Loss:"
@8,20 say netloss
cap = cap + aint - netloss
endif
@8,30 say cap
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 aint
read
if netpro > 0
@8,2 say "(+)Net pro"
@8,20 say netpro
cap = cap + aint + netpro
else
@8,2 say "(-)Net Loss:"
@8,20 say netloss
cap = cap + aint - netloss
endif
@8,30 say cap
@9,2 say "Reserve Fund"
@9,30 get rsrv
read
liab = 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 land
ass = land + cashb + cashh
@10,2 say repl("-",75)
@11,30 say liab
@11,68 say ass
@12,2 say repl("-",75)
wait window
return
@9,30 get rsrv
read
liab = 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 land
ass = land + cashb + cashh
@10,2 say repl("-",75)
@11,30 say liab
@11,68 say ass
@12,2 say repl("-",75)
wait window
return