home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: InfoMgt / InfoMgt.zip / kim21.zip / REPORT.KIM < prev    next >
Text File  |  1995-07-31  |  24KB  |  1,040 lines

  1.   rem Programm       : Formularausgabe 1.0
  2.   rem Programmierer  : Kohlenbach
  3.   rem Datum          : Sept/Okt 1994
  4.  
  5.   rem 1. Öffnen einer bestehenden Maskendatei und zerlegen dieser
  6.  
  7.   defstring zeile,rechts,links,_rand,_datei,expr,tmpzeile,_ausgabe,_endkey,zz$
  8.   defstring seite$
  9.   defstring _masterdb,_slavedb,_index,zeichen,_startkey,zeichen2,_seitenvorschub
  10.   deffloat _seitenlen,_vorschub,zz,seite,yy
  11.   deffloat _anzahldb1,_anzahldb2,_index_feld,_kopien
  12.   deffloat jkflag
  13.  
  14.   deffloat _vergleich_num,_ver1,_ver2
  15.   dim tet,1,3
  16.   dim jkteile,1,3
  17.  
  18.   deffloat a,b,c,d,e,f,g,h,i,j,k,l,x,y,anzahl,flag,wert,anzahl_felder,ii,aa
  19.   deffloat _steuerzahl
  20.   deffloat _top_anzahl,_body_anzahl,_bottom_anzahl,_flags_anzahl,_end_anzahl
  21.   defstring _body_leerzeilen,_body_trennzeile,_aufsteigend
  22.   defstring _import_body,_import_top,_import_bottom,_import_end
  23.  
  24.   dim zeilen         ,1,100
  25.   dim druck_z        ,1,50
  26.   dim teile          ,1,50
  27.   dim _steuer        ,1,50
  28.   dim _steuercode    ,1,50
  29.   dim _body_zeilen   ,1,50
  30.   dim _top_zeilen    ,1,50
  31.   dim _bottom_zeilen ,1,50
  32.   dim _end_zeilen    ,1,50
  33.   dim _name          ,1,50
  34.   dim _flags         ,1,50
  35.   dim _calc          ,1,30
  36.   dim _calcname      ,1,30
  37.   dim _var           ,1,30
  38.  
  39.   rem Variablen für Importteile
  40.   rem *************************************************
  41.   dimfloat _zahl     ,1,30
  42.   dim _string        ,1,30
  43.   
  44.  
  45.   deffloat _calc_anzahl
  46.   dimfloat _total,1,10
  47.  
  48.   anzahl_felder=120
  49.   _seitenlen=68
  50.   dim _master,1,anzahl_felder
  51.   dim _slave,1,anzahl_felder
  52.  
  53.   fillstr 80,_rand," "
  54.  
  55.   exist "datei.dte",a
  56.   if a<>1 then
  57.     msgbox "Datei : DATEI.DTE konnte nicht gefunden werden ",0,a,""
  58.     end
  59.   else
  60.     import "datei.dte"
  61.   endif
  62.  
  63.   rem _datei="rechnung.rpt"
  64.   _aufsteigend="ja"
  65.  
  66.   loadfont "C8","Courier" ,8
  67.   loadarray _datei,zeilen,1,100,anzahl
  68.  
  69.   compress2 zeilen,1,anzahl
  70.  
  71.   rem Ermittlung der Datenbanken und Felder
  72.   flag=0
  73.   for i=1 to anzahl
  74.     if zeilen[i]=".def" then flag=1 : endif
  75.     if zeilen[i]=".top" then flag=2 : i=anzahl+1 : endif
  76.  
  77.     if flag=1 then
  78.       in zeilen[i],"=",a
  79.       if a<>-1 then
  80.  
  81.         mid zeilen[i],links,1,a-1
  82.         mid zeilen[i],rechts,a+1,50
  83.         compress rechts,links
  84.         ltrim rechts,links
  85.         lcase links
  86.         replace rechts,'"',""
  87.         rem Analysiere Ausdruck auf der linken Seite
  88.  
  89.         rem ** Steuercodes **
  90.         mid links,zeichen,1,1
  91.         if zeichen="#" then
  92.  
  93.           clear teile,1,50
  94.           select rechts,44,teile,1,50
  95.           _steuerzahl=_steuerzahl+1
  96.           _steuer[_steuerzahl]="*"+links+"*"
  97.           _steuercode[_steuerzahl]=""
  98.  
  99.           for x=1 to 50
  100.             if teile[x]<>"" then
  101.               val teile[x],y
  102.               zeichen=""
  103.               stradd zeichen,chr(y)
  104.               _steuercode[_steuerzahl]=_steuercode[_steuerzahl]+zeichen
  105.             else
  106.               x=51
  107.             endif
  108.           next
  109.         endif
  110.  
  111.         rem Eigenschaften für Felder
  112.         if zeichen="!" then
  113.           _flags_anzahl=_flags_anzahl+1
  114.           _flags[_flags_anzahl]=rechts
  115.           _name[_flags_anzahl]=links
  116.         endif
  117.  
  118.         rem Kalkulationen für Felder
  119.         if zeichen="$" then
  120.           _calc_anzahl=_calc_anzahl+1
  121.           _calc[_calc_anzahl]=rechts
  122.           _calcname[_calc_anzahl]=links
  123.         endif
  124.  
  125.  
  126.         if links="drucker" then
  127.  
  128.           exist rechts,a
  129.           if a=1 then
  130.             loadarray rechts,druck_z,1,50,aa
  131.             for II=1 to aa
  132.               rem ** Steuercodes **
  133.               in druck_z[ii],"=",a
  134.               mid druck_z[ii],links,1,a-1
  135.               mid druck_z[ii],rechts,a+1,50
  136.               compress rechts,links
  137.               ltrim rechts,links
  138.               lcase links
  139.               replace rechts,'"',""
  140.               mid links,zeichen,1,1
  141.               if zeichen="#" then
  142.                 clear teile,1,50
  143.                 select rechts,44,teile,1,50
  144.                 _steuerzahl=_steuerzahl+1
  145.                 _steuer[_steuerzahl]="*"+links+"*"
  146.                 _steuercode[_steuerzahl]=""
  147.                 for x=1 to 50
  148.                   if teile[x]<>"" then
  149.                     val teile[x],y
  150.                     zeichen=""
  151.                     stradd zeichen,chr(y)
  152.                     _steuercode[_steuerzahl]=_steuercode[_steuerzahl]+zeichen
  153.                   else
  154.                     x=51
  155.                   endif
  156.                 next
  157.               endif
  158.             next
  159.           endif
  160.         endif
  161.  
  162.  
  163.         rem Kopienzahl
  164.         if links="kopien" then
  165.           val rechts,_kopien
  166.         endif
  167.  
  168.         rem Importdateien *********************************************
  169.         if links="import_body" then
  170.           _import_body=rechts
  171.         endif
  172.  
  173.         if links="import_top" then
  174.           _import_top=rechts
  175.         endif
  176.         if links="import_bottom" then
  177.           _import_bottom=rechts
  178.         endif
  179.         if links="import_end" then
  180.           _import_body=rechts
  181.         endif
  182.  
  183.  
  184.  
  185.         rem ** Datei **
  186.  
  187.         if links="ausgabe" then
  188.           _ausgabe=rechts
  189.         endif
  190.  
  191.         rem *** Leerzeile entfernen
  192.  
  193.         if links="body_leerzeilen" then
  194.           _body_leerzeilen=rechts
  195.         endif
  196.  
  197.         rem *** Trennzeile einfügen
  198.  
  199.         if links="body_trennzeile" then
  200.           _body_trennzeile=rechts
  201.         endif
  202.  
  203.  
  204.         rem ** Startkey **
  205.  
  206.         if links="startkey" then
  207.           _startkey=rechts
  208.         endif
  209.  
  210.         rem ** Endkey **
  211.  
  212.         if links="endkey" then
  213.           _endkey=rechts
  214.         endif
  215.         rem ** Seitenvorschub am Schluß **
  216.         if links="seitenvorschub" then
  217.           _seitenvorschub=rechts
  218.         endif
  219.         rem ** Indexfeld **
  220.         if links="index_feld" then
  221.           val rechts,wert
  222.           _index_feld=wert
  223.         endif
  224.         rem ** Vorschub **
  225.         if links="vorschub" then
  226.           val rechts,wert
  227.           _vorschub=wert
  228.         endif
  229.         rem ** Seitenlänge **
  230.         if links="seitenlen" then
  231.           val rechts,wert
  232.           _seitenlen=wert
  233.         endif
  234.         rem ** Linker Rand **
  235.         if links="rand" then
  236.           val rechts,wert
  237.           mid _rand,_rand,1,wert
  238.         endif
  239.         rem ** Masterdatenbank **
  240.         if links="masterdb" then
  241.           _masterdb=rechts
  242.         endif
  243.         rem ** Slavedatenbank **
  244.         if links="slavedb" then
  245.           _slavedb=rechts
  246.         endif
  247.         rem *** Auf/Absteigend der Slavedb
  248.         if links="aufsteigend" then
  249.           _aufsteigend=rechts
  250.         endif
  251.         rem ** Index **
  252.         if links="index" then
  253.           _index=rechts
  254.         endif
  255.       endif
  256.     endif
  257.   next
  258.  
  259.  
  260.   if flag=0 then
  261.     msgbox "Keinen Definitionsteil gefunden",0,a,""
  262.     end
  263.   endif
  264.   if _ausgabe="" then
  265.     msgbox "Keine Ausgabedatei angegeben",0,a,""
  266.     end
  267.   endif
  268.  
  269.   rem Prüfen ob DTE-Datei vorhanden
  270.   exist "report.dte",a
  271.   if a=1 then
  272.     import "report.dte"
  273.   endif
  274.  
  275.  
  276.   rem Prüfen ob DTE-Datei vorhanden
  277.   exist "startkey.dte",a
  278.   if a=1 then
  279.     open 7,"startkey.dte","r"
  280.     jkflag=1
  281.   endif
  282.  
  283.  
  284. #toprun
  285.  
  286.   if jkflag=1 then
  287.     gets 7,zeile
  288.     select zeile,44,jkteile,1,2
  289.     compress zeile
  290.     if jkteile1="EOF" or zeile="" then
  291.        close 7
  292.        kill "startkey.dte"
  293.        end
  294.     else
  295.        _startkey=jkteile1
  296.        val jkteile2,_kopien
  297.     endif
  298.   endif
  299.  
  300.  
  301.   rem Masterdatenbank öffnen
  302.   if _masterdb<>"" then
  303.     iopen 1,_masterdb
  304.     iopen_index 1,_masterdb
  305.     iset 1,_index,expr
  306.     igetstruct 1,_master,_slave,_anzahldb1
  307.     select _master[_index_feld],44,tet,1,3
  308.     compress tet2
  309.     ltrim tet2
  310.     ucase tet2
  311.     if tet2="N" then
  312.       _vergleich_num=1
  313.     endif
  314.  
  315.   endif
  316.  
  317.  
  318.  
  319.   rem Falls Slavedatenbank vorhanden dann auch öffnen
  320.  
  321.   if _slavedb<>"" then
  322.     iopen 2,_slavedb
  323.     iopen_index 2,_slavedb
  324.     iset 2,_index,expr
  325.     igetstruct 2,_master,_slave,_anzahldb2
  326.     select _master[_index_feld],44,tet,1,3
  327.     compress tet2
  328.     ltrim tet2
  329.     ucase tet2
  330.     if tet2="N" then
  331.       _vergleich_num=1
  332.     endif
  333.  
  334.   def_window "rep_win",15,5, 55,7
  335.   def_border "rep_border"
  336.   def_titel  "rep_titel","Meldung" ;"center"
  337.   def_prompt "rep_pr",5,1,"Datei : ",_datei,"  ---> ",_ausgabe
  338.   def_prompt "rep_pr2",5,2,"                                    "
  339.   def_prompt "rep_pr3",5,3,"                                    "
  340.  
  341.   add_item "rep_win","rep_border","rep_titel","rep_pr","rep_pr2","rep_pr3"
  342.   win_paint "rep_win"
  343.  
  344.  
  345.   
  346.  
  347.   rem Ausgabedatei öffnen
  348.   kill _ausgabe
  349.   open 1,_ausgabe
  350.  
  351. for yy=1 to _kopien
  352.  
  353.     clear _total,1,10
  354.     seite=0
  355.  
  356.     istart 1,_master
  357.     iread 1,a,_startkey,_master
  358.     if a<>0 then
  359.       msgbox "Keinen entsprechenden Datensatz gefunden",0,a,""
  360.       iclose 1
  361.       end
  362.     endif
  363.  
  364.     istart 2,_slave
  365.     iread 2,a,_startkey,_slave
  366.  
  367.     if a<>0 then
  368.       msgbox "Keinen rel. Datensatz in Slave gefunden",0,a,""
  369.       _anzahldb2=0 : rem Keine weitere Feldprüfung
  370.     endif
  371.   endif
  372.  
  373.   set_item "rep_pr2","Analysiere Report  "
  374.   set_item "rep_pr3","TOP  "
  375.   gosub #get_top
  376.   set_item "rep_pr3","BODY  "
  377.   gosub #get_body
  378.   set_item "rep_pr3","BOTTOM  "
  379.   gosub #get_bottom
  380.   set_item "rep_pr3","END  "
  381.   gosub #get_end
  382.  
  383.   set_item "rep_pr2","Druck...  "
  384.   gosub #druck_top
  385.   gosub #druck_body
  386.   gosub #druck_bottom
  387.   gosub #druck_end
  388.   
  389.   if _seitenvorschub="ja" or _kopien>0 then
  390.     puts 1,chr(12),
  391.   endif
  392.  
  393. next
  394.   
  395.  
  396. close 1
  397.   
  398.  
  399.   if _masterdb<>"" then  iclose 1 : endif
  400.   if _slavedb<>""  then  iclose 2 : endif
  401.  
  402. if jkflag=0 then
  403.   event_on_item "rep_win","end"
  404. endif
  405.  
  406.   if _ausgabe="screen" then
  407.     call show_datei("screen")
  408.   endif
  409.  
  410.   if jkflag=1 then
  411.     goto #toprun
  412.   endif
  413.  
  414.   end
  415.   rem ********************* Ende ***************************
  416.  
  417.   rem *******************************************************************************
  418.   rem Routine um den Kopf jeder Seite zu Drucken
  419.   rem *******************************************************************************
  420.  
  421.   #druck_top
  422.  
  423.   exist _import_top,a
  424.   if a=1 then
  425.     import _import_top
  426.   endif
  427.   
  428.  
  429.   seite=seite+1         : rem Seitenzahl erhöhen
  430.   form seite,seite$,0,1 : rem Seite in String
  431.   zz=0                  : rem Anzahl der Zeilen auf Null setzen
  432.  
  433.   rem 0. Vorschub falls angegeben
  434.   if _vorschub>0 then
  435.     for i=1 to _vorschub
  436.       puts 1,""
  437.       zz=zz+1
  438.       gosub #info
  439.     next
  440.   endif
  441.  
  442.   rem 1. ** Ermittlung des Kopfteils **
  443.   for i=1 to _top_anzahl
  444.     tmpzeile=_top_zeilen[i]
  445.     call zeile_wandeln(tmpzeile,seite)
  446.     puts 1,tmpzeile
  447.     zz=zz+1
  448.     gosub #info
  449.     if zz>_seitenlen-_bottom_anzahl then
  450.       gosub #seite_neu
  451.     endif
  452.   next
  453.  
  454.   return
  455.  
  456.  
  457.   #druck_body
  458.  
  459.   a=0
  460.  
  461.   #hhh
  462.  
  463.   if _vergleich_num=0 then
  464.  
  465.     while _slave[_index_feld]=_startkey and a<>3 and a<>4
  466.       gosub #druck_body2
  467.     wend
  468.  
  469.     if _endkey<>"" then
  470.       while _slave[_index_feld]<=_endkey and a<>3 and a<>4
  471.         gosub #druck_body2
  472.       wend
  473.     endif
  474.  
  475.   else
  476.  
  477.     val _startkey,_ver1
  478.     val _slave[_index_feld],_ver2
  479.     while _ver1=_ver2 and a<>3 and a<>4
  480.       gosub #druck_body2
  481.       val _slave[_index_feld],_ver2
  482.     wend
  483.  
  484.     if _endkey<>"" then
  485.       val _endkey,_ver1
  486.       val _slave[_index_feld],_ver2
  487.  
  488.       while _ver2 <=_ver1
  489.         gosub #druck_body2
  490.         val _slave[_index_feld],_ver2
  491.         if a=3 or a=4 then
  492.           _ver2=1
  493.           _ver1=0
  494.         endif
  495.       wend
  496.     endif
  497.  
  498.   endif
  499.  
  500.   return
  501.  
  502.   rem ********************************************************************
  503.  
  504.   #druck_body2
  505.  
  506.   exist _import_body,a
  507.   if a=1 then
  508.     import _import_body
  509.   endif
  510.  
  511.   igetrec 2,_slave
  512.   rem 1. ** Druck Body **
  513.   for i=1 to _body_anzahl
  514.     tmpzeile=_body_zeilen[i]
  515.     call zeile_wandeln(tmpzeile,seite)
  516.     compress tmpzeile
  517.     if _body_leerzeilen="ja" then
  518.       puts 1,tmpzeile
  519.       zz=zz+1
  520.       gosub #info
  521.       rem if zz>_seitenlen-_bottom_anzahl then
  522.       rem   gosub #seite_neu
  523.       rem endif
  524.     else
  525.       if tmpzeile<>"" then
  526.         puts 1,tmpzeile
  527.         zz=zz+1
  528.         gosub #info
  529.         rem if zz>_seitenlen-_bottom_anzahl then
  530.         rem   gosub #seite_neu
  531.         rem endif
  532.       endif
  533.     endif
  534.   next
  535.  
  536.   if zz>_seitenlen-_bottom_anzahl then
  537.      gosub #seite_neu
  538.   endif
  539.   
  540.   rem Trennzeile druckem
  541.   if _body_trennzeile="ja" then
  542.     puts 1,""
  543.     zz=zz+1
  544.     gosub #info
  545.     if zz>_seitenlen-_bottom_anzahl then
  546.       gosub #seite_neu
  547.     endif
  548.   endif
  549.  
  550.   if _aufsteigend="ja" then
  551.     inext 2,a,_slave
  552.   else
  553.     iprev 2,a,_slave
  554.   endif
  555.  
  556.   return
  557.  
  558.  
  559.  
  560.  
  561.  
  562.   #druck_bottom
  563.  
  564.   exist _import_bottom,a
  565.   if a=1 then
  566.     import _import_bottom
  567.   endif
  568.  
  569.   
  570.  
  571.   for i=1 to _bottom_anzahl
  572.     tmpzeile=_bottom_zeilen[i]
  573.     call zeile_wandeln(tmpzeile,seite)
  574.     puts 1,tmpzeile
  575.     zz=zz+1
  576.     gosub #info
  577.   next
  578.   return
  579.  
  580.  
  581.   #druck_end
  582.  
  583.   exist _import_end,a
  584.   if a=1 then
  585.     import _import_end
  586.   endif
  587.  
  588.   for i=1 to _end_anzahl
  589.     tmpzeile=_end_zeilen[i]
  590.     call zeile_wandeln(tmpzeile,seite)
  591.     puts 1,tmpzeile
  592.     zz=zz+1
  593.     gosub #info
  594.   next
  595.   return
  596.  
  597.  
  598.  
  599.   #seite_neu
  600.   gosub #druck_bottom
  601.   puts 1,chr(12)
  602.   gosub #druck_top
  603.   return
  604.  
  605.  
  606.  
  607.   rem *******************************************************************************
  608.   rem Routine um den Kopf zu ermitteln
  609.   rem *******************************************************************************
  610.  
  611.   #get_top
  612.  
  613.   _top_anzahl=0
  614.   
  615.   flag=0
  616.   rem 1. ** Ermittlung des Kopfteils **
  617.   for i=1 to anzahl
  618.     tmpzeile=zeilen[i]
  619.     compress tmpzeile
  620.     if tmpzeile=".top" then flag=2 : endif
  621.     if tmpzeile=".bottom" or tmpzeile=".body" then flag=3 : i=anzahl+1 : endif
  622.  
  623.     if flag=2 and tmpzeile<>".top" then
  624.       _top_anzahl=_top_anzahl+1
  625.       _top_zeilen[_top_anzahl]=tmpzeile
  626.     endif
  627.   next
  628.   return
  629.  
  630.  
  631.  
  632.   rem *******************************************************************************_body
  633.   rem Routine um den Mittelteil jeder Seite zu ermitteln
  634.   rem *******************************************************************************
  635.  
  636.   #get_body
  637.   _body_anzahl=0
  638.   flag=1
  639.   rem 1. ** Das erste Mal drucken wie gehabt **
  640.   for i=1 to anzahl
  641.     tmpzeile=zeilen[i]
  642.     compress tmpzeile
  643.     if tmpzeile=".body" then flag=2 : endif
  644.     if tmpzeile=".bottom" then flag=3 : i=anzahl+1 : endif
  645.     if flag=2 and tmpzeile<>".body" then
  646.       _body_anzahl=_body_anzahl+1
  647.       _body_zeilen[_body_anzahl]=tmpzeile
  648.     endif
  649.   next
  650.   return
  651.  
  652.   #get_bottom
  653.   _bottom_anzahl=0
  654.   flag=1
  655.   for i=1 to anzahl
  656.     tmpzeile=zeilen[i]
  657.     compress tmpzeile
  658.     if tmpzeile=".bottom" then flag=2 : endif
  659.     if tmpzeile=".end" then flag=3 : i=anzahl+1 : endif
  660.     if flag=2 and tmpzeile<>".bottom" then
  661.       _bottom_anzahl=_bottom_anzahl+1
  662.       _bottom_zeilen[_bottom_anzahl]=tmpzeile
  663.     endif
  664.   next
  665.   return
  666.  
  667.   #get_end
  668.   _end_anzahl=0
  669.   flag=1
  670.   for i=1 to anzahl
  671.     tmpzeile=zeilen[i]
  672.     compress tmpzeile
  673.     if tmpzeile=".end" then flag=2 : endif
  674.     if flag=2 and tmpzeile<>".end" then
  675.       _end_anzahl=_end_anzahl+1
  676.       _end_zeilen[_end_anzahl]=tmpzeile
  677.     endif
  678.   next
  679.   return
  680.  
  681.   rem *******************************************************************************_body
  682.   modul zeile_wandeln(char tmpzeile,float seite)
  683.  
  684.     deffloat a,i,x,y,flag
  685.     defstring zeichen,seite$,date$,aus$,text$
  686.     form seite,seite$,0,1
  687.     datum date$,3
  688.     dim aus,1,20
  689.     deffloat aus_anzahl
  690.  
  691.  
  692.     rem 1. Prüfen ob Leerzeile
  693.     if tmpzeile="" then
  694.       exitmod
  695.     else
  696.       rem 2. Prüfen ob Zeile ohne Steuercodes mit Text vorhanden ist
  697.       in tmpzeile,"*",a
  698.       if a=-1 then
  699.         tmpzeile=_rand+tmpzeile
  700.         exitmod
  701.       else
  702.         rem 3. Zeile enthält Steuercodes
  703.         rem 3a) Steuercodetabelle in entspr. Plätze einsetzen
  704.  
  705.         in tmpzeile,"#",a
  706.         if a<>-1 then
  707.           for x=1 to _steuerzahl
  708.             replace tmpzeile,_steuer[x],_steuercode[x]
  709.           next
  710.         endif
  711.  
  712.  
  713.  
  714.         len tmpzeile,y
  715.  
  716.         rem Ermittlung aller Felder im Report -> speichern im Array AUS
  717.  
  718.         aus$=""
  719.         for x=1 to y
  720.           mid tmpzeile,zeichen,x,1
  721.           if zeichen="*" and flag=0 then
  722.             flag=1
  723.           else
  724.             if zeichen="*" and flag=1 then
  725.               flag=0
  726.               aus_anzahl=aus_anzahl+1
  727.               aus[aus_anzahl]=aus$
  728.               aus$=""
  729.             endif
  730.           endif
  731.           if flag=1 then
  732.             aus$=aus$+zeichen
  733.           endif
  734.         next
  735.  
  736.         rem Felder aus DB holen
  737.  
  738.  
  739.         for i=1 to aus_anzahl
  740.           call feld_holen(aus[i],tmpzeile)
  741.         next
  742.  
  743.  
  744.         rem 3d) Diverse Variable prüfen
  745.         replace tmpzeile,"*seite*",seite$
  746.         replace tmpzeile,"*datum*",date$
  747.  
  748.         tmpzeile=_rand+tmpzeile
  749.  
  750.       endif
  751.     endif
  752.   endmod
  753.  
  754.   modul feld_holen( char zeile,char tmpzeile)
  755.  
  756.     defstring zeichen,wert1,text,zeichen2,feldnamen,text$,text2$,total$,altzeile
  757.     defstring such,wert0
  758.     deffloat i,x,a,wert3,wert2,total,wert4
  759.  
  760.     dim ttt,1,10
  761.  
  762.     mid zeile,altzeile,2,100
  763.  
  764.     zeile=zeile+"*"
  765.  
  766.  
  767.     mid zeile,wert1,2,1
  768.     mid zeile,zeichen,3,3
  769.     val zeichen,wert2
  770.  
  771.     rem Intervall prüfen und falls kein Feld dann zurück
  772.  
  773.     if wert1="a" then
  774.       if wert2<1 or wert2 >_anzahldb1 then
  775.         exitmod
  776.       endif
  777.     else
  778.       if wert1="b" then
  779.         if wert2<1 or wert2 >_anzahldb2 then
  780.           exitmod
  781.         endif
  782.       else
  783.         rem Berechnungen
  784.         rem _ = Nur anzeigen
  785.         rem + = Anzeigen und Berechnung im Def-Teil durchführen
  786.         rem & = Berechnung durchführen nicht anzeigen
  787.         if wert1="_"  or wert1="&" or wert1="+" then
  788.  
  789.           mid zeile,wert0,2,4
  790.           if wert0="_var" then
  791.             mid zeile,wert0,6,2
  792.             form wert0,zeichen2,0,1
  793.             feldnamen="!_var"+zeichen2
  794.             in zeile,"-",a
  795.             if a=-1 then
  796.               wert3=0
  797.             else
  798.               len zeile,wert3
  799.             endif
  800.             val zeichen2,a
  801.             total$=_var[a]
  802.             call eigenschaften(feldnamen,wert3,total$)
  803.             replace tmpzeile,zeile,total$
  804.             exitmod
  805.           endif
  806.           
  807.           mid altzeile,wert1,1,1
  808.           if wert1="&" or wert1="+" then
  809.             mid altzeile,altzeile,2,100
  810.           endif
  811.           in zeile,"-",a
  812.           if a=-1 then
  813.             wert3=0
  814.           else
  815.             len zeile,wert3
  816.             in altzeile,"-",a
  817.             mid altzeile,altzeile,1,a-1
  818.           endif
  819.           if wert1="+" or wert1="&" then
  820.             such="$"+altzeile
  821.             find _calcname,1,_calc_anzahl,such,i
  822.             if i>0 then
  823.               eval _calc[i],total
  824.               mid _calcname[i],total$,2,100
  825.               &total$&=total
  826.             endif
  827.           endif
  828.           total=0
  829.           total$=""
  830.           eval altzeile,total
  831.           form total,total$,2,1
  832.           feldnamen="!"+altzeile
  833.           call eigenschaften(feldnamen,wert3,total$)
  834.           if wert1="&" then
  835.             replace tmpzeile,zeile,""
  836.           else
  837.             replace tmpzeile,zeile,total$
  838.           endif
  839.           exitmod
  840.         else
  841.           exitmod
  842.         endif
  843.       endif
  844.     endif
  845.  
  846.     form wert2,zeichen2,0,1
  847.     feldnamen="!"+wert1+zeichen2
  848.  
  849.     in zeile,"-",a
  850.     if a=-1 then
  851.       wert3=0
  852.     else
  853.       len zeile,wert3
  854.     endif
  855.  
  856.  
  857.     if wert1="a" then
  858.       rem 3b) DB-Felder prüfen und einsetzen MASTER-DB
  859.       igetrec 1,_master
  860.     else
  861.       rem 3c) In der Slave-DB wenn vorhanden
  862.       igetrec 2,_master
  863.     endif
  864.  
  865.     compress _master[wert2]
  866.     ltrim _master[wert2]
  867.  
  868.     if wert3<>0 then
  869.       mid _master[wert2],text,1,wert3
  870.       set wert3,text
  871.       rem Eigenschaften prüfen
  872.       call eigenschaften(feldnamen,wert3,text)
  873.     else
  874.       text=_master[wert2]
  875.     endif
  876.     replace tmpzeile,zeile,text
  877.  
  878.  
  879.  
  880.   endmod
  881.  
  882.   rem WERT3 - > die Länge des Strings
  883.   modul eigenschaften(char feldnamen,float wert3,char text)
  884.     deffloat a,i
  885.     dim teile,1,10
  886.  
  887.  
  888.     find _name,1,_flags_anzahl,feldnamen,a
  889.     if a>0 then
  890.       clear teile,1,10
  891.       select _flags[a],44,teile,1,10
  892.       compress2 teile,1,10
  893.       i=1
  894.       while teile[i]<>"" then
  895.         if teile[i]="ucase" then ucase text : endif
  896.         if teile[i]="lcase" then lcase text : endif
  897.  
  898.         if teile[i]="rset"  then
  899.           compress text
  900.           rset wert3,text
  901.         endif
  902.         if teile[i]="lset"  then
  903.           ltrim text
  904.           compress text
  905.           set wert3,text
  906.         endif
  907.  
  908.         if teile[i]="dez0"  then
  909.           form text,text,0,wert3
  910.         endif
  911.         if teile[i]="dez1"  then
  912.           form text,text,1,wert3
  913.         endif
  914.         if teile[i]="dez2"  then
  915.           form text,text,2,wert3
  916.         endif
  917.         if teile[i]="dez3"  then
  918.           form text,text,3,wert3
  919.         endif
  920.         i=i+1
  921.       wend
  922.     endif
  923.  
  924.   endmod
  925.  
  926.   #info
  927.   form zz,zz$,0,1
  928.   zz$="Seite : "+seite$+"    Zeile : "+zz$
  929.   set_item "rep_pr3",zz$
  930.   return
  931.  
  932.   MODUL show_datei(char datei)
  933.  
  934.     defstring objekt,id$,i$,zeile
  935.     deffloat ok,i,taste
  936.  
  937.  
  938.     def_window "win_info",0,2, 91,18 ;"modal"
  939.     def_border "win_info_border"
  940.     def_titel  "win_info_titel","Ausgabe" ;"center"
  941.     def_max_button "win_max_b"
  942.     add_item "win_info","win_info_border","win_max_b","win_info_titel"
  943.  
  944.     DEF_TOOLBAR   "tool_info",0,0,0,0;"region off","border"
  945.     DEF_SCROLLBAR "scroll_info",1,0,0,0,0
  946.     DEF_BUTTON    "PushButton1",3,1,15,"","Quit";""
  947.     DEF_BUTTON    "PushButton2",13,1,15,"","Druck LPT1";""
  948.     DEF_BUTTON    "PushButton3",23,1,15,"","Druck LPT2";""
  949.     DEF_LIST "text_info",0,1,0,87,15,0,0 ;"border","c8","select off"
  950.  
  951.     add_item "text_info","scroll_info"
  952.     add_item "tool_info","PushButton1","PushButton2","PushButton3"
  953.     ADD_ITEM "win_info","tool_info","text_info"
  954.  
  955.     i=1
  956.     open 11,datei,"r"
  957.  
  958.     gets 11,zeile
  959.     gets 11,zeile
  960.     while zeile<>"EOF"
  961.        form i,i$,0,1
  962.        id$="text"+i$
  963.        def_string id$,1,0,80,zeile
  964.        add_item "text_info",id$
  965.       rem event_on_item "text_info","redisplay"
  966.        gets 11,zeile
  967.        i=i+1
  968.     wend
  969.     close 11
  970.  
  971.     win_paint "win_info"
  972.  
  973.     while i<>1000
  974.       win_ev i
  975.       get_item_pos objekt,taste
  976.       if taste=13 and objekt="PushButton1" then
  977.         kill datei
  978.         i=1000
  979.       endif
  980.       if taste=13 and objekt="PushButton2" then
  981.          call info_druck(datei,"lpt1")
  982.          i=1000
  983.       endif
  984.       if taste=13 and objekt="PushButton3" then
  985.          call info_druck(datei,"lpt2")
  986.          i=1000
  987.       endif
  988.  
  989.     wend
  990.  
  991.     event_on_item "win_info","end"
  992.  
  993.   ENDMOD
  994.    
  995.   MODUL info_druck(char datei_send,char datei_empf)
  996.         defstring zeile
  997.  
  998.         call tmp_fenster(1)
  999.  
  1000.         open 11,datei_send,"r"
  1001.         open 12,datei_empf
  1002.         gets 11,zeile
  1003.         while zeile <> "EOF"
  1004.            puts 12,zeile
  1005.            gets 11,zeile
  1006.         wend
  1007.         close 11
  1008.         close 12
  1009.         call tmp_fenster(0)
  1010.         kill datei_send
  1011.   ENDMOD
  1012.  
  1013.   MODUL tmp_fenster(float flag)
  1014.  
  1015.      if flag=1 then
  1016.         def_window "msg_be",30,7,26,6 ;"move off","modal"
  1017.         def_border "msg_border_be"
  1018.         def_titel  "msg_titel_be","Meldung" ;"center"
  1019.         def_prompt "msg_pr1_be",1,1,"Daten werden gedruckt"
  1020.         def_prompt "msg_pr2_be",5,2,"Bitte warten !"
  1021.  
  1022.         add_item "msg_be",..
  1023.         "msg_border_be",..
  1024.         "msg_titel_be",..
  1025.         "msg_pr1_be",..
  1026.         "msg_pr2_be"
  1027.         win_paint "msg_be"
  1028.      else
  1029.         event_on_item "msg_be","end"
  1030.      endif
  1031.  
  1032.   ENDMOD
  1033.  
  1034.    
  1035.    
  1036.    
  1037.  
  1038.  
  1039.  
  1040.