Browse lookups are the saving grace of filePro. They take much of the hard coding out of viewing and manipulating your data. Moreover, they allow relatively new programmers the ability to write some very sophisticated programs.
NOTE: Keep in mind that files with creation passwords prevents fields from being displayed in a browse lookup unless the field is included on the screen. This provides a way of protecting data from unauthorized viewing.
Here is a fairly generic application written solely based on a browse lookup. It stands users in one file and allows them to Add, Modify or Delete records in another file, while keeping some simple totals in the current file.
File Name: npiwarestand
Number |
------Field Heading------- |
Len |
--Type-- |
|
|
|
|
1 |
Spec# |
5 |
.0 |
2 |
Seq# |
3 |
.0 |
3 |
cartons |
5 |
,0 |
4 |
R |
0 |
|
5 |
pounds |
8 |
,0 |
6 |
descr1 |
28 |
|
7 |
CustCode |
6 |
|
8 |
roll/case weight |
5 |
.1 |
|
Key segment record length: 60 |
There is no data segment. |
File Name: npiwarestand
Screen: 1
+- Totals for SPEC# !1 -----------------------------+
| Cartons Pounds |
| !ta !tc |
| !6 |
| !7 |
+------------------------------------------------------+
File Name: npiwarestand
Screen: add
+------------------------------------------------------------------------------+
| SEC#: !oa Shift: !ob |
+------------------------------------------------------------------------------+
| |
| Date In/Out P# Cartons Skids Pounds Comment |
| *ob *oh *od *oe *of !og *oi |
| |
+------------------------------------------------------------------------------+
Cursor Path:
12
TAB
2
1
3
TAB
10
4
5
8
File Name: npiwarestand
Screen: goto
+-----------------------+
| Goto which S# or P# |
| |
| SPEC#: *s |
| |
| P#: *p |
| |
| |
| Press ESC ESC to Go |
| |
| Press DEL to cancel |
+-----------------------+
File Name: npiwarestand Printed: May 6 1997 14:04 Page 1
Output Format: list-noval (fP 4), Dated: Mar 4 12:04:11 1997
10 20 30 40 50 60 70 80
: | : | : | : | : | : | : | : |
H E A D I N G / T I T L E L I N E S
Nexus Plastics, Inc. Date: *@td
Warehouse #2 Inventory Page:<@pn
SPEC# Cust Description Cartons Pounds
--------------------------------------------------------------------
D A T A L I N E S
*1 *7 *6 *3 *5
___________________________ T O T A L L I N E S ______________________________
G R A N D T O T A L
Cartons Pounds
Totals: =3 =5
E N D O F F O R M
File Name: npiwarestand Printed: May 6 1997 14:04 Page 2
Output Format: list-noval (fP 4), Dated: Mar 4 12:04:11 1997
Sort Field: 1
Length: 5
Descending:
Subtotal Field:
Align form: N
Remove blank lines: N
Grand Total new page: Y
Printer:
Initial print code:
Final print code:
File Name: npiwarestand
Processing Table: list-noval
If: 3 eq "" and 5 eq ""
Then: end
Then: print
Then: end
File Name: npiwarestand
Browse Format: default
Spec# Cust Description Cartons Pounds
*1 *7 *6 *3 *5
Number --------------Field Heading--------------
1 Spec#
7 CustCode
6 descr1
3 cartons
5 pounds
File Name: npiwaredet
Number |
----------Field Heading---------- |
Len |
--Type-- |
1 |
spec# |
5 |
.0 |
2 |
date |
8 |
mdy/ |
3 |
seq# |
3 |
.0 |
4 |
P# |
5 |
.0 |
5 |
cartons |
5 |
,0 |
6 |
r |
0 |
|
7 |
pounds |
7 |
,0 |
8 |
in/out |
3 |
|
9 |
comment |
20 |
|
10 |
initials |
3 |
|
File Name: npiwarestand
Processing Table: automatic
Then: ff(14,,g)="npiwaredet"
If: fl eq ""
Then: display "blank";end
Then: display 1 ; end
File Name: npiwarestand
Processing Table: input
Then: 'run with "rreport npiwarestand -sblank -lx -d"
Then: gosub realtot
Then: end
@menu If:
Then:
If: bk eq "set"
Then: bk="";end
If: in ne ""
Then: exit
Then: input popup in(3,,g) "What are your initials? "
If: @sk eq "BRKY"
Then: exit
If: in eq ""
Then: goto @menu
Then: pushkey "11[ENTR]G";end
@keyG If:
Then:
Then: cls("20")
Then: s(5,allup,g)="";p(5,allup,g)=""
Then: popup update -,"goto"
If: @sk eq "SAVE"
Then: clearp;goto dogo
If: @sk eq "BRKY"
Then: clearp;end
If: 'stopgap not needed
Then: end
dogo If:
Then:
Then: fl="1"
If: s eq "" and p eq ""
Then: end
If: s ne ""
Then: goto dos
dop If:
Then: lookup npio k=p i=a -nx
If: not npio
Then: lookup npio = npioarch k=p i=a -nx
If: not npio
Then: show "@P# not on file, try again.";end
Then: s=npio(3)
dos If:
Then: lookup npis k=s i=a -nx
If: not npis
Then: show "@Sorry, that SPEC# is not on file!";show "";end
Then: rc(5,.1,g)=npis(44)
Then: da(28,,g)=npis(22) ; db(6,,g)=npis(2)
Then: kg=s
Then: lookup tst=npiwarestand k=kg i=a -nx
If: not tst
Then: goto addnew
Then: lookup - k=kg i=a -nx
Then: end
addnew If:
Then: lookup - r=free -ep
Then: 1=s ; 8=rc ; 6=da ; 7=db ; write ; display ; pushkey "[SAVE]";end
@keyD If:
Then: input popup q " \r Are you SURE you want to DELETE EVERY ENTRY on t
his Date/Shift?
(y/n) \r "
If: q ne "Y"
Then: end
Then: gosub killall
Then: gosub clrflds
Then: end
killall If:
Then: kd=1
Then: lookup eat=(ff) k=kd i=a -nx
moreat If: not eat
Then: return
If: eat(1) ne 1
Then: return
Then: delete eat;getnext eat;goto moreat
clrflds If:
Then:
Then: ta(6,,0)=""; tc(8,,0)=""
Then: return
@keyU If:
Then:
If: @rn eq "1"
Then: show "@Goto a Spec# first... then press U again.";show "";end
getdet If: '*getdet
Then:
Then: gosub tstnew
If: n eq "1"
Then: goto contold
Then: input popup q "No entries yet, would you like to add some? (y/n) "
If: q ne "Y"
Then: end
Then: cls("20");gosub clrvars;gosub adddet;goto @keyU
Then: '
contold If:
Then: gosub gettots
Then: cls("20")
Then: display
Then: gosub prompts
Then: ky=1
brw1 If: '*brw1
Then:
Then: za="(brw=13,7,1 xkey=AMDX show=pkeep prc=proc1 mlen=5 fill=asc)"
Then: zb="[Date P# In/Out Cartons Skids Pounds Comment
Ini]"
Then: zc= "*2 *4 *8 *5 *6 *7 *9
*10"
Then: lookup bom=(ff) k=ky i=a -ngm b=(za&zb&zc)
If: @sk="SAVE"
Then: cls("20");clearb;goto cleanup
If: @sk="BRKY"
Then: cls("20");clearb;goto cleanup
If: @bk="X"
Then: cls("20");clearb;gosub realtot;clearb;end
If: @bk="D"
Then: cls("20");gosub deldet;gosub gettots
If: @bk="D" and n eq ""
Then: cls("20");clearb;df="";goto getdet
If: @bk="D" and n eq "1"
Then: n="";gosub gettots;cls("20");gosub prompts;goto brw1
If: @bk="A"
Then: cls("20");gosub clrvars;gosub adddet;gosub gettots;cls("20");gosub
prompts;goto brw1
If: @bk="M"
Then: cls("20");gosub clrvars;gosub ldvars;gosub moddet;gosub gettots;cls
("20");gosub prompts;goto brw1
Then: goto brw1
proc1 If:
Then:
Then: end
deldet If: '*deldet
Then:
Then: cls("20")
Then: beep
Then: input popup q(1,yesno) " \r Are you SURE you want to delete this
entry? (y/n) \r "
If: q ne "Y"
Then: return
Then: delete bom
Then: gosub realtot
Then: gosub tstnew
Then: return
adddet If: '*adddet
Then:
Then: lookup bom=(ff) r=free -ep
Then: bom(1)=1
moddet If:
Then: oa=1
Then: cls("20")
Then: gosub prompt2
Then: BREAK OFF
Then: popup update -,"add",ob
If: ob&od&oe&of eq ""
Then: write bom;delete bom;clearp;return
Then: BREAK ON
Then: bom(2)=ob
Then: bom(4)=od ; bom(5)=oe ; bom(6)=of ; bom(7)=og
If: oh eq "o"
Then: bom(8)="out"
If: oh eq "i"
Then: bom(8)="in"
Then: bom(9)=oi ; bom(10)=in
If: bom(3) eq ""
Then: 2=2+"1" ; bom(3)=2
Then: write
Then: ky=1&bom(3)
Then: clearp ; return
@entsel If:
Then:
If: @sk eq "BRKY"
Then: exit
Then: gosub gettots
Then: gosub legend
Then: end
legend If: '*legend
Then:
Then: cls("20")
Then: show("21","1") "---------------------------------------------------
----------------------------"
Then: show("22","1") "\r U \rpdate/View entries"
Then: show("24","1") "\r G \roto another SPEC#"
Then: show("22","53") "\r D \relete this entire SPEC#"
Then: show("24","67") "\r X \r=Exit"
Then: show("24","37") "\r L \r=List records (browse)"
Then: show("22","37") "Select >"
Then: return
gettots If:
Then:
Then: gosub clrflds
Then: kt=1
Then: lookup det=(ff) k=kt i=a -nx
mordet If: not det
Then: goto fintots
If: det(1) ne 1
Then: goto fintots
If: det(8) eq "in"
Then: goto doin
doout If:
Then: ta=ta-det(5)
Then: tc=tc-det(7)
Then: getnext det ; goto mordet
doin If:
Then: ta=ta+det(5)
Then: tc=tc+det(7)
Then: getnext det;goto mordet
fintots If:
Then:
If: ta eq "0"
Then: ta=""
If: tc eq "0"
Then: tc=""
Then: display;return
realtot If:
Then: 3=ta;5=tc;write
Then: display;return
prompts If: '*prompts
Then:
Then: cls("20")
Then: cb="Use UP and DOWN arrows or NxtPg and PrvPg to scroll entries."
Then: show ("22","40"-dlen(cb)/"2") cb
Then: cc="\r A \r to Add an entry, \r M \r to Modify an entry, \r D \r to
Delete an entry. \r X \r=Exit"
Then: show ("24","40"-dlen(cc)/"2") cc
Then: return
prompt2 If:
Then: cd="Press \r ESC ESC \r to Save, \r DEL \r to cancel."
Then: show ("24","40"-dlen(cc)/"2") cd
Then: return
clrvars If: '*clrvars
Then:
Then: oa(5,.0)="";ob(8,mdy/)=""
Then: oc(3)="";od(5,.0)="";oe(4,.0)="";of(2,.0)="";og(7,.1)=""
Then: return
ldvars If: '*ldvars
Then:
Then: ob=bom(2) ; od=bom(4);oe=bom(5);of=bom(6);og=bom(7)
Then: oh=bom(8);oi=bom(9)
Then: return
tstnew If:
Then: kn=1
Then: lookup new=(ff) k=kn i=a -nx
If: not new
Then: n="";return
Then: n="1";return
@whelp If:
Then: help "main";end
@wlfs If: s ne ""
Then: p = "" ; display ; end
Then: display;end
@wlfp If: p ne ""
Then: s = "" ; display ; end
Then: display;end
cleanup If:
Then:
Then: end
@wlfob If: ob eq ""
Then: screen ,ob
If: ob lt "01/01/97"
Then: show "Date out of range";screen ,d
Then: show "";end
@wlfoe If:
Then:
Then: og=oe*8
Then: display;end
@wlfoh If: oh ne "i" and oh ne "o"
Then: screen ,oh
Then: end
@keyL If:
Then: video off
Then: bk(3,,g)="set"
If: 1 eq "0"
Then: pushkey "x4a"{1{"[ENTR]b" ; end
Then: pushkey "x4a"{1{"b" ; end