P. 1
AL_ADHOC

AL_ADHOC

|Views: 12|Likes:
Published by Kai Middleton
This is an old dBase program (Clipper to be precise) that allows the user to put together an ad hoc query: it determines the fields in a table and allows the user to form a valid boolean expression of those fields plus user-chosen constants.
This is an old dBase program (Clipper to be precise) that allows the user to put together an ad hoc query: it determines the fields in a table and allows the user to form a valid boolean expression of those fields plus user-chosen constants.

More info:

Published by: Kai Middleton on Apr 23, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

01/08/2016

pdf

text

original

1

****************************************************************************
2 *
3 * Program: al_adhoc.prg
4 *
5 * Authors: Kai Middleton
6 *
7 * Written: 8-87
8 *
9 *
10 * Function: generate a report on up to eleven fields
11 * from up to 8 databases
12 * by creating or retrieving an ad hoc query
13 *
14 ****************************************************************************
15
16
17
18 * - - - - D A T A B A S E S - - - - - - - - - - - - - - -
19 * querfldc/querfldf query.prg
20 * querydbc/querydbf query.prg and this proc
21 * dispfldc/dispfldf (aka dict or dict2)
22 * CURRENT AREA: FINAL AREA:
23 * loan almastf
24 * particpn particpn
25 * spprods spprods
26 * collatrl
27 * borrower
28 * obligor
29
30 IF current
31 querydb = "querydbc"
32 querfld = "querfldc"
33 ELSE
34 querydb = "querydbf"
35 querfld = "querfldf"
36 ENDIF
37
38 PRIVATE choice
39
40 choice=1
41 DO WHILE true
42 mqueryname=SPACE(60)
43 mquerystr=SPACE(254)
44 recnum=0
45 maxpos=4
46 m1="Generate-Query"
47 m2="Query-Library"
48 m3="Delete"
49 m4="Exit"
50 mh1="Generate a New Query"
51 mh2="Use a Query from the Query Library"
52 mh3="Delete a Query from the Query Library."
53 mh4="Return to Previous Menu"
54
55 DO utmenu2 WITH maxpos,choice,;
56 m1,m2,m3,m4,m5,m6,m7,m8,m9,mh1,mh2,mh3,mh4,mh5,mh6,mh7,mh8,mh9
57
58 kontinue=false
59
60 DO CASE
61 CASE choice=1
62 *
63 **
64 DO utquery WITH querfld
65 **
66 *
67 IF kontinue=true
68 DO savequer
69 DO ahrept
70 ENDIF
71 CASE choice=2
72 DO quersel WITH "Queries - Select"
73 IF kontinue=true
74 DO ahrept
75 ENDIF
76 CASE choice=3
77 DO querdel
78 CASE choice=4
79 key=esc
80 EXIT
81 ENDCASE
82 ENDDO
83
84 * Make this into a separate prg w/ 2 nested ovls
85 * the following code is 1 and utquery is 2
86
87
88
89 *------------------------------------------------------------------------------
90 PROCEDURE savequer
91 *------------------------------------------------------------------------------
92 * save the query into &querydb if the user desires.
93
94 title="Query - Store"
95 scrid="ALRSadxx"
96 nav="Enter Query Name and Press PgDn to Continue"
97
98 DO alpaint2 WITH header,title, scrid, nav
99
100 ans=sp
101 SET ESCAPE OFF
102 @ 11,00 SAY "Do you wish to save this query for future reference? (Y/N) ";
103 GET ans PICTURE "!" VALID (ans $ "YN")
104 READ
105 SET ESCAPE ON
106
107 IF ans=no
108 RETURN
109 ENDIF
110
111 @ 11,00
112 mqueryname=SPACE(60)
113 DO WHILE true
114 SET CONFIRM ON
115 @ 11,00 SAY "Description: " GET mqueryname
116 READ
117 SET CONFIRM OFF
118 IF LASTKEY()<>esc
119 EXIT
120 ENDIF
121 DO utmsg WITH ;
122 "Are you sure you wish to abandon naming the query (Y/N)? ",nav
123 IF ans=yes
124 RETURN
125 ENDIF
126 ENDDO
127
128 IF use_x(querydb)
129 IF r_append()
130 REPLACE xqueryname WITH mqueryname
131 REPLACE xquerystr WITH mquerystr
132 ENDIF
133 ENDIF
134
135 USE
136
137
138 *------------------------------------------------------------------------------
139 PROCEDURE quersel
140 *------------------------------------------------------------------------------
141 * query select get a pre-stored query from &querydb
142
143 PARAMETERS title
144
145 scrid="ALRSadxx"
146 nav= chr(30)+"(Up),"+chr(31)+"(Dn),PgUp,PgDn,";
147 +"Ctrl+PgUp(top),Ctrl+PgDn(bottom),Enter(select),Esc(Exit)"
148
149 DO alpaint2 WITH header,title, scrid, nav
150
151 tlrow=5
152 tlcol=1
153 brrow=20
154 brcol=60
155 f1="xqueryname"
156 fnum=1
157 create_box=true
158
159 IF .NOT. use_x(querydb)
160 RETURN
161 ENDIF
162 IF EOF()
163 USE
164 DO utmsgwt WITH "Sorry, there are no queries in the database yet."
165 ELSE
166 **
167 DO utscrn7
168 **
169 mquerystr=xquerystr
170 mqueryname=xqueryname
171 recnum=RECNO()
172 USE
173 IF key<>esc
174 kontinue=true
175 ENDIF
176 ENDIF
177
178
179 *------------------------------------------------------------------------------
180 PROCEDURE querdel
181 *------------------------------------------------------------------------------
182 * delete a query from the query library.
183
184 DO quersel WITH "Queries - Delete"
185
186 IF kontinue=false
187 RETURN
188 ENDIF
189
190 DO utmsg WITH "Are you sure you wish to delete this query (Y/N)? ",nav
191
192 IF ans=yes
193 IF .NOT. use_x(querydb)
194 RETURN
195 ENDIF
196 GO recnum
197 IF .NOT. r_lock()
198 USE
199 RETURN
200 ENDIF
201 DELETE
202 UNLOCK
203 USE
204 ENDIF
205
206
207 *------------------------------------------------------------------------------
208 *-----------------------<><><>-------------------------------------------------
209 PROCEDURE ahrept
210 *-----------------------<><><>-------------------------------------------------
211 *------------------------------------------------------------------------------
212 * ad hoc report - flow of control for output starts here
213
214 PRIVATE selectable
215
216 selectable=11
217 * && - - - these arrays all get set up in procedure rptset - - -
218 DECLARE acolpos[selectable] && column position - the COL()/PCOL() position on the screen/page where the output will go.
219 DECLARE afldactual[selectable] && field actual - contains something like "STR(xentityid)" or "'$'+numf2(xamount)
220 DECLARE adbfkeyx[selectable] && dbf key x (x meaning in the db) - equals "xloanno" "xentityid"
221 DECLARE adbfkeym[selectable] && dbf key m (m meaning a memvar) - equals "mloanno" "mentityid"
222 DECLARE adbf[selectable] && database name - the database used to display the field in a given column
223 DECLARE adescrip[selectable] && description - the header at the top of each column
224 DECLARE alookup[selectable] && lookup fields - for fields like xrau or xliabtype, this will hold the name of a
225 DECLARE dbfarray[7] && dbf array - contains all the unique databases so that the work areas can be setup
226 DECLARE ntxarray[7] && ntx array - contains all the unique indexes so that the work areas can be setup
227 numofdbfs=0
228
229 DO WHILE true
230 ansvalid="ans $ 'SP'"
231 DO utmsg WITH "Output to Screen or Printer (S/P)? "
232 IF key<>esc
233 output_to=ans
234 EXIT
235 ENDIF
236 DO utmsg WITH "Are you sure you wish to abandon (Y/N)? "
237 IF ans=yes
238 RETURN
239 ENDIF
240 ENDDO
241
242 DO WHILE true
243 kontinue=false
244 DO getflds
245 IF kontinue=true
246 EXIT
247 ELSE
248 SET ESCAPE OFF
249 DO utmsg WITH "Do you wish to abandon this Ad Hoc Report (Y/N)? "
250 SET ESCAPE ON
251 IF ans=yes
252 RETURN
253 ENDIF
254 ENDIF
255 ENDDO
256
257 DO hoc_out
258
259
260 *------------------------------------------------------------------------------
261 PROCEDURE getflds
262 *------------------------------------------------------------------------------
263 * get fields - let the user select which fields to output on the report.
264
265 title="Display Fields - Select"
266 scrid ="ALRSadxx"
267 nav=chr(30)+"(Up),"+chr(31)+"(Dn),PgUp,PgDn,Esc(Exit),";
268 +"Enter(select),Ctrl+End(Exit with Selections)"
269
270 DO alpaint2 WITH header, title, scrid, nav
271
272 @ 04,01 SAY "Database Field Length"
273 * XXXXXXXX 123456789012345678 00X SELECTED
274 f1="xdbfname+sp"
275 f2="xdescrip+sp"
276 f3="STR(xlenactual,3)"
277 fnum=3
278 tlrow=6
279 tlcol=1
280 brrow=20
281 brcol=42
282 create_box=true
283 selecting=true
284 numselctd=0
285 spec_use1=true
286 spec_key1=ctrlend
287 spec_proc1="lenvalid"
288 spec_ret1=false
289 arrsize=185
290 endpoint=185
291 eofile=true
292 DECLARE aview[arrsize]
293 DECLARE arecno[arrsize]
294 pre_loaded=false
295 pre_load=true
296
297 IF .NOT. use_x( IF(current,"dispfldc","dispfldf") )
298 RETURN
299 ENDIF
300 *
301 DO utscrn7
302 *
303 IF key<>esc .AND. numselctd>0
304 DO rptset
305 kontinue=true
306 ENDIF
307 USE
308
309
310 *------------------------------------------------------------------------------
311 PROCEDURE lenvalid
312 *------------------------------------------------------------------------------
313 * length valid - check to see if the report output will be too long
314
315 PRIVATE lencount
316 PRIVATE rec
317
318 incr=1
319 lencount=0
320 rec=RECNO()
321
322 DO WHILE incr<=numselctd
323 GO selerecs[incr]
324 lencount=lencount+MAX(20,MIN(xlenactual+2,32))
325 incr=incr+1
326 ENDDO
327
328 IF output_to=to_scrn
329 IF lencount>80
330 DO utmsg WITH "Total field length is too long. ";
331 +"Output to print instead (Y/N)? ",nav
332 IF ans=yes
333 selectable=11
334 output_to=to_prn
335 KEYBOARD CHR(ctrlend)
336 ENDIF
337 ELSE
338 spec_ret1=true
339 ENDIF
340 ELSE
341 IF lencount>226
342 DO utmsgwt WITH "Total Field Length too long: 226 is the limit, your ";
343 +"total is "+LTRIM(STR(lencount)),nav
344 ELSE
345 spec_ret1=true
346 ENDIF
347 ENDIF
348
349 GO rec
350
351
352 *------------------------------------------------------------------------------
353 PROCEDURE rptset
354 *------------------------------------------------------------------------------
355 * report setup - fill the arrays needed for report output.
356 * called from getfield if kontinue<>esc
357 * database in use is dispfld?.dbf
358
359 PRIVATE pos
360
361 colpos=0
362 incr=1
363 DO WHILE incr<=numselctd
364 GO selerecs[incr]
365 acolpos[incr]=colpos
366 colpos=colpos+MAX(MIN(xlenactual+2,32),20)
367 afldactual[incr]=xfldactual
368 adescrip[incr]=xdescrip
369 adbfkeyx[incr]=dbfkey(xdbfname)
370 adbfkeym[incr]="m"+SUBSTR(adbfkeyx[incr],2,LEN(adbfkeyx[incr])-1)
371 adbf[incr]=LOWER(ALLTRIM(xdbfname))
372 alookup[incr]=RTRIM(xlookup)
373 IF ASCAN(dbfarray,LOWER(ALLTRIM(xdbfname)))=0
374 numofdbfs=numofdbfs+1
375 dbfarray[numofdbfs]=LOWER(RTRIM(xdbfname))
376 ntxarray[numofdbfs]=thentxof(xdbfname)
377 ENDIF
378 incr=incr+1
379 ENDDO
380
381
382 *------------------------------------------------------------------------------
383 FUNCTION dbfkey
384 *------------------------------------------------------------------------------
385 * database key - the key field linking a db to the master db
386 * (the master db being either loan or almastf)
387
388 PARAMETERS dbf
389 dbf=LOWER(ALLTRIM(dbf))
390
391 DO CASE
392 CASE dbf="collatrl"
393 RETURN("xloanno")
394 CASE dbf="particpn" .OR. dbf="partf"
395 RETURN("xloanno")
396 CASE dbf="spprods"
397 RETURN("xloanno")
398 CASE dbf="obligor"
399 RETURN("xentityid")
400 CASE dbf="borrower"
401 RETURN("xentityid")
402 CASE dbf="lrels" .OR. dbf="lrelsf"
403 RETURN("xloanno")
404 CASE dbf="fininfo" .OR. dbf="fininfof"
405 RETURN("xloanno")
406 OTHERWISE
407 RETURN(null)
408 ENDCASE
409
410
411 *------------------------------------------------------------------------------
412 FUNCTION thentxof
413 *------------------------------------------------------------------------------
414 * the index of - return the .ntx file corresponding to a db
415
416 PARAMETERS dbf
417 dbf=LOWER(ALLTRIM(dbf))
418
419 DO CASE
420 CASE dbf="collatrl"
421 RETURN("colxloan")
422 CASE dbf="particpn" .OR. dbf="partf"
423 RETURN("parxloan")
424 CASE dbf="spprods"
425 RETURN("sppxloan")
426 CASE dbf="obligor"
427 RETURN("oblxenti")
428 CASE dbf="borrower"
429 RETURN("borxenti")
430 CASE dbf="lrels" .OR. dbf="lrelsf"
431 RETURN("lrexloan")
432 CASE dbf="fininfo" .OR. dbf="fininfof"
433 RETURN("finxloan")
434 OTHERWISE
435 RETURN(null)
436 ENDCASE
437
438
439 *------------------------------------------------------------------------------
440 *-----------------------<><><>-------------------------------------------------
441 PROCEDURE hoc_out
442 *-----------------------<><><>-------------------------------------------------
443 *------------------------------------------------------------------------------
444 * ad hoc output - spit out the report
445
446 PRIVATE mpstring
447 PRIVATE mpend
448 PRIVATE line
449
450 * - - - - - - O P E N D A T A B A S E S - - - - - - - - - - - - - - - - - -
451 IF current
452 maindb="loan"
453 ELSE
454 maindb="almastf"
455 ENDIF
456
457 **
458 IF .NOT. dbfset()
459 RETURN
460 ENDIF
461 **
462
463 @ 23,00 CLEAR
464 @ 23,00 SAY "Filtering Records for the query - Please Wait"
465 DO seledbf WITH maindb
466 SET FILTER TO &mquerystr
467 GO TOP
468 IF EOF()
469 CLOSE DATA
470 DO utmsgwt WITH "Sorry, no records match the query criteria."
471 RETURN
472 ENDIF
473
474 mentityid=0
475 mloanno=0
476 mqueryname=ALLTRIM(mqueryname)
477 IF LEN(mqueryname)=0
478 mqueryname="Untitled Ad Hoc Query"
479 ELSE
480 mqueryname="Ad Hoc Query - "+mqueryname
481 ENDIF
482
483 * - - - - - - S E T U P P R I N T E R / S C R E E N - - - - - - - - - - - -
484 page=0
485 IF output_to=to_scrn
486 CLEAR
487 botline=24-2
488 line=REPLICATE(CHR(196),80)
489 ELSE
490 mpstring='CHR(27)+"(0U"+CHR(27)+"&l4h84P"+CHR(27)+"(s0T"+CHR(27)+"&l1o"+CHR(27)+"(s0P"+CHR(27)+"(s16.6H"'
491 mpend='chr(27)+"E"'
492 CLEAR
493 @ 23,00
494 SET PRINT ON
495 ?? &mpstring
496 SET PRINT OFF
497 CLEAR
498 @ 12,28 SAY "Printing Ad Hoc Report."
499 SET CONSOLE OFF
500 SET DEVICE TO PRINT
501 botline=45-1
502 line=REPLICATE("_",226)
503 ENDIF
504 first=true
505 row1=1
506
507 * - - - - - - A R R A Y S T O H O L D O U T P U T C O L U M N S - - -
508 maxovflow=16 && previously 9 -- kai
509 DECLARE colcount[numselctd]
510 incr=1
511 DO WHILE incr<=numselctd
512 colcount[incr]=0
513 incr=incr+1
514 ENDDO
515 incr=1
516 DO WHILE incr<=numselctd
517 incr2=LTRIM(STR(incr))
518 DECLARE acol&incr2[maxovflow]
519 incr=incr+1
520 ENDDO
521 * you end up with acol1[9], acol2[9], acol3[9], up to acol11[9]
522 * or less as needed.
523 * When displaying, the longest a line will be is 240, but only 30 can be
524 * shown, so this means up to 7 more lines are needed for overflow. Since
525 * up to 10 special products need to be displayed, this larger limit is used.
526
527
528 *
529 * either loan.dbf or almastf.dbf is in use for the following loop.
530 *
531 * = = = = = = = = D R I V E R L O O P = = = = = = = = = = = = = = = = = = =>
532 DO rpthed
533 abort=false
534 DO WHILE .NOT. abort .AND. .NOT. EOF()
535 **
536 DO rec_out
537 **
538 DO seledbf WITH maindb
539 SKIP
540 ENDDO
541 * = = = = = = = = E N D D R I V E R L O O P = = = = = = = = = = = = = = =>
542
543
544
545
546 * - - - - - - - - C L E A N U P W O R K A R E A - - - - - - - - - - - -
547
548 CLOSE DATA
549
550 IF output_to=to_scrn
551 IF .NOT. abort
552 KEYBOARD null
553 @ 24,00 SAY "The Ad Hoc Report is Done. Press any key to continue."
554 INKEY(0)
555 ENDIF
556 ELSE
557 EJECT
558 SET DEVICE TO SCREEN
559 SET PRINT ON
560 ?? &mpend
561 SET PRINT OFF
562 SET PRINTER TO
563 ENDIF
564
565
566 *------------------------------------------------------------------------------
567 FUNCTION dbfset
568 *------------------------------------------------------------------------------
569 * set up all the databases and indexes that were selected in rptset
570 *
571 * Maximum possible result for current directory
572 *
573 * SELECT 1 loan ALIAS almastf
574 * SELECT 2 borrower INDEX borxenti ALIAS borrower
575 * SELECT 3 collatrl INDEX colxloan ALIAS collatrl
576 * SELECT 4 obligor INDEX oblxenti ALIAS obligor
577 * SELECT 5 lrels INDEX lrexloan ALIAS lrelsf
578 * SELECT 6 fininfo INDEX finxloan ALIAS fininfof
579 * SELECT 7 particpn INDEX parxloan ALIAS partf
580 * SELECT 8 spprods INDEX sppxloan ALIAS spprods
581 *
582 * Maximum possible result for final directory
583 *
584 * SELECT 1 final\almastf ALIAS almastf
585 * SELECT 2 final\lrelsf INDEX final\lrexloan ALIAS lrelsf
586 * SELECT 3 final\fininfof INDEX final\finxloan ALIAS fininfof
587 * SELECT 4 final\partf INDEX final\parxloan ALIAS partf
588 * SELECT 5 final\spprods INDEX final\sppxloan ALIAS spprods
589
590
591 IF current
592 dbfpath=null
593 ELSE
594 dbfpath=mfdir+backslash
595 ENDIF
596
597 incr=1
598 DO WHILE incr<=numofdbfs
599 SELECT(incr)
600 realdbf=dbfpath+dbfarray[incr]
601 ntx=ntxarray[incr]
602 ntx=IF(LEN(TRIM(ntx))=0,null,dbfpath+ntx)
603 IF .NOT. use_x(realdbf)
604 CLOSE DATA
605 RETURN(false)
606 ENDIF
607 SET INDEX TO &ntx
608 incr=incr+1
609 ENDDO
610
611 IF ASCAN(dbfarray,maindb)=0
612 * if loan/almastf database hasn't already been opened, open it.
613 SELECT(incr)
614 realdbf=dbfpath+maindb
615 numofdbfs=numofdbfs+1
616 dbfarray[numofdbfs]=maindb
617 IF .NOT. use_x(realdbf,false,maindb)
618 CLOSE DATA
619 RETURN(false)
620 ENDIF
621 ENDIF
622
623 RETURN(true)
624
625
626 *------------------------------------------------------------------------------
627 PROCEDURE seledbf
628 *------------------------------------------------------------------------------
629 * SELECT the dbf. This procedure is necessary because use_x will not
630 * allow the use of alias names.
631 * Logically equivalent to SELECT &dbf,
632 * except that the alias names are not in use.
633
634 PARAMETERS dbf
635
636 PRIVATE incr
637
638 FOR incr=1 TO numofdbfs
639 IF dbf=dbfarray[incr]
640 SELECT(incr)
641 RETURN
642 ENDIF
643 NEXT
644
645 ? "Error in proc seledbf - please call Lambda Group."
646 WAIT
647
648
649 *------------------------------------------------------------------------------
650 PROCEDURE rpthed
651 *------------------------------------------------------------------------------
652 * report header
653
654 PRIVATE message
655
656 IF output_to=to_scrn
657 CLEAR
658 ELSE
659 IF first
660 first=false
661 ELSE
662 EJECT
663 ENDIF
664 ENDIF
665
666 page=page+1
667
668 IF output_to=to_scrn
669 @ 01,00 SAY mqueryname
670 @ 01,80-12 SAY " Page: "+LTRIM(STR(page))
671 row1=2
672 ELSE
673 @ 01,01 SAY "DATE: "+DTOC(DATE())
674 @ 01,(226-LEN(mcompany))/2 SAY mcompany
675 @ 02,01 SAY "TIME: "+TIME()
676 @ 02,(226-LEN(mqueryname))/2 SAY mqueryname
677 @ 02,210 SAY "Page: "+LTRIM(STR(page))
678 @ 03,00 SAY line
679 row1=4
680 ENDIF
681
682 counter=1
683 DO WHILE counter<=numselctd
684 @ row1,acolpos[counter] SAY adescrip[counter]
685 counter=counter+1
686 ENDDO
687
688 row1=row1+1
689 @ row1,00 SAY line
690 row1=row1+1
691 IF output_to=to_prn
692 row1=row1+1
693 @ row1,00 SAY null
694 ENDIF
695
696
697 *------------------------------------------------------------------------------
698 PROCEDURE rec_out
699 *------------------------------------------------------------------------------
700 * record output - output a single record
701
702 * these vars correspond to adbfkeym[]
703 IF current
704 mentityid=xentityid
705 mloanno=xloanno
706 ELSE
707 mentityid=VAL(xentityid)
708 mloanno=xloanno
709 ENDIF
710
711 colincr=1
712 DO WHILE colincr<=numselctd
713 dbf=adbf[colincr]
714 DO seledbf WITH dbf
715 IF row1>botline
716 IF rptesc()
717 RETURN && this can only happen if outputting to screen
718 ENDIF
719 DO rpthed
720 ENDIF
721 IF dbf=maindb && maindb="loan" or maindb="almastf"
722 DO elemwork
723 ELSE
724 keym=adbfkeym[colincr]
725 keyx=adbfkeyx[colincr]
726 SEEK &keym
727 IF FOUND()
728 DO elemwork
729 ENDIF
730 ENDIF
731 colincr=colincr+1
732 ENDDO
733
734 incr=1
735 maxvar=0
736 DO WHILE incr<=numselctd
737 maxvar=MAX(maxvar,colcount[incr])
738 incr=incr+1
739 ENDDO
740
741 incr=1
742 row1=row1+1
743 DO WHILE incr<=maxvar
744 IF row1>botline
745 IF rptesc()
746 RETURN
747 ENDIF
748 DO rpthed
749 ENDIF
750 incr2=1
751 DO WHILE incr2<=numselctd
752 IF colcount[incr2]>=incr
753 incr3=LTRIM(STR(incr2))
754 @ row1,acolpos[incr2] SAY acol&incr3[incr]
755 ENDIF
756 incr2=incr2+1
757 ENDDO
758 incr=incr+1
759 row1=row1+1
760 ENDDO
761
762 incr=1
763 DO WHILE incr<=numselctd
764 colcount[incr]=0
765 incr=incr+1
766 ENDDO
767
768 row1=row1+1
769
770
771 *------------------------------------------------------------------------------
772 PROCEDURE elemwork
773 *------------------------------------------------------------------------------
774 * element work - work the field into the proper form, then output it.
775 * also, prepare the col arrays to hold any overflow from the element
776
777 elemlength=0
778 element=null
779
780 DO convelem
781
782 @ row1,acolpos[colincr] SAY SUBSTR(element,1,30)
783
784 * fill up the acol array.
785
786 IF dbf $ "lrels lrelsf fininfo fininfof particpn partf spprods"
787 DO m_to_one
788 ELSE
789 DO overflow
790 ENDIF
791
792
793 *------------------------------------------------------------------------------
794 PROCEDURE convelem
795 *------------------------------------------------------------------------------
796 * convert element - convert element to a displayable form
797
798 PRIVATE dbf2
799 PRIVATE workarea
800
801 IF LEN(alookup[colincr])<>0 .AND. (current .OR. alookup[colincr]="specprds")
802 **
803 * field selected was a lookup code.
804 **
805 workarea=SELECT()
806 mcode=afldactual[colincr]
807 mcode=&mcode
808 dbf2=alookup[colincr]
809 SELECT(0) && next available workarea
810 IF .NOT. use_x(dbf2)
811 element=null
812 ELSE
813 LOCATE FOR mcode=xcode && if not found, will give blanks which is ok.
814 element=xdesc
815 USE
816 ENDIF
817 SELECT(workarea)
818 ELSE
819 element=afldactual[colincr]
820 element=anytoc(&element)
821 ENDIF
822
823 element=ALLTRIM(element)
824 elemlength=LEN(element)
825
826
827 *------------------------------------------------------------------------------
828 PROCEDURE m_to_one
829 *------------------------------------------------------------------------------
830 * many to one - the database chosen (spprods or particpn)
831 * was one with a many to one relationship to maindb (loan/almastf),
832 * so display up to ten of the related records.
833
834 PRIVATE incr2
835 PRIVATE incr4
836 PRIVATE maxlines
837 PRIVATE rec
838 PRIVATE reccount
839
840 rec=RECNO()
841 COUNT WHILE &keym=&keyx TO reccount
842 GO rec
843 * reccount = number of records related to the maindb record
844 maxlines=INT(maxovflow/reccount)
845
846 incr2=1
847 incr3=LTRIM(STR(colincr))
848 incr4=1 && line 1 of the element has been displayed in proc elemwork
849
850 DO WHILE incr4 <= maxlines .AND. incr2<=maxovflow .AND. incr4*30+1<=elemlength
851 acol&incr3[incr2]=SUBSTR(element,incr4*30+1,30)
852 incr4=incr4+1
853 incr2=incr2+1
854 ENDDO
855
856 SKIP
857 DO WHILE &keym=&keyx .AND. incr2<=maxovflow
858 DO convelem
859 incr4=0
860 DO WHILE incr4 < maxlines .AND. incr2<=maxovflow .AND. incr4*30+1<=elemlength
861 acol&incr3[incr2]=SUBSTR(element,incr4*30+1,30)
862 incr4=incr4+1
863 incr2=incr2+1
864 ENDDO
865 DO seledbf WITH dbf
866 SKIP
867 ENDDO
868 colcount[colincr]=incr2-1
869
870
871 *------------------------------------------------------------------------------
872 PROCEDURE overflow
873 *------------------------------------------------------------------------------
874 * put the rest of variable element into an array if it's longer than 30
875
876 PRIVATE incr2
877
878 incr2=1
879 DO WHILE incr2*30<elemlength
880 incr3=LTRIM(STR(colincr))
881 acol&incr3[incr2]=SUBSTR(element,incr2*30+1,30)
882 incr2=incr2+1
883 ENDDO
884 colcount[colincr]=incr2-1
885
886
887 *------------------------------------------------------------------------------
888 FUNCTION rptesc
889 *------------------------------------------------------------------------------
890 * report escape - if outputting to screen, pause for page break,
891 * and give user an opportunity to escape.
892
893 IF output_to=to_prn
894 RETURN(false)
895 ENDIF
896
897 KEYBOARD null
898 DO WHILE true
899 @ 24,00 SAY "Press any key for the next screen, Esc to abort."
900 key=INKEY(0)
901 IF key=esc
902 DO utmsg WITH "Are you sure you wish to abandon (Y/N)? "
903 IF key=esc
904 LOOP
905 ENDIF
906 IF ans=yes
907 abort=true
908 RETURN(true)
909 ENDIF
910 ENDIF
911 RETURN(false)
912 ENDDO
913
914
915 * °±²ÛÜÝÞßþ••þßÞÝÜÛ²±°
916 •

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->