home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: InfoMgt
/
InfoMgt.zip
/
kim21.zip
/
REPORT.KIM
< prev
next >
Wrap
Text File
|
1995-07-31
|
24KB
|
1,040 lines
rem Programm : Formularausgabe 1.0
rem Programmierer : Kohlenbach
rem Datum : Sept/Okt 1994
rem 1. Öffnen einer bestehenden Maskendatei und zerlegen dieser
defstring zeile,rechts,links,_rand,_datei,expr,tmpzeile,_ausgabe,_endkey,zz$
defstring seite$
defstring _masterdb,_slavedb,_index,zeichen,_startkey,zeichen2,_seitenvorschub
deffloat _seitenlen,_vorschub,zz,seite,yy
deffloat _anzahldb1,_anzahldb2,_index_feld,_kopien
deffloat jkflag
deffloat _vergleich_num,_ver1,_ver2
dim tet,1,3
dim jkteile,1,3
deffloat a,b,c,d,e,f,g,h,i,j,k,l,x,y,anzahl,flag,wert,anzahl_felder,ii,aa
deffloat _steuerzahl
deffloat _top_anzahl,_body_anzahl,_bottom_anzahl,_flags_anzahl,_end_anzahl
defstring _body_leerzeilen,_body_trennzeile,_aufsteigend
defstring _import_body,_import_top,_import_bottom,_import_end
dim zeilen ,1,100
dim druck_z ,1,50
dim teile ,1,50
dim _steuer ,1,50
dim _steuercode ,1,50
dim _body_zeilen ,1,50
dim _top_zeilen ,1,50
dim _bottom_zeilen ,1,50
dim _end_zeilen ,1,50
dim _name ,1,50
dim _flags ,1,50
dim _calc ,1,30
dim _calcname ,1,30
dim _var ,1,30
rem Variablen für Importteile
rem *************************************************
dimfloat _zahl ,1,30
dim _string ,1,30
deffloat _calc_anzahl
dimfloat _total,1,10
anzahl_felder=120
_seitenlen=68
dim _master,1,anzahl_felder
dim _slave,1,anzahl_felder
fillstr 80,_rand," "
exist "datei.dte",a
if a<>1 then
msgbox "Datei : DATEI.DTE konnte nicht gefunden werden ",0,a,""
end
else
import "datei.dte"
endif
rem _datei="rechnung.rpt"
_aufsteigend="ja"
loadfont "C8","Courier" ,8
loadarray _datei,zeilen,1,100,anzahl
compress2 zeilen,1,anzahl
rem Ermittlung der Datenbanken und Felder
flag=0
for i=1 to anzahl
if zeilen[i]=".def" then flag=1 : endif
if zeilen[i]=".top" then flag=2 : i=anzahl+1 : endif
if flag=1 then
in zeilen[i],"=",a
if a<>-1 then
mid zeilen[i],links,1,a-1
mid zeilen[i],rechts,a+1,50
compress rechts,links
ltrim rechts,links
lcase links
replace rechts,'"',""
rem Analysiere Ausdruck auf der linken Seite
rem ** Steuercodes **
mid links,zeichen,1,1
if zeichen="#" then
clear teile,1,50
select rechts,44,teile,1,50
_steuerzahl=_steuerzahl+1
_steuer[_steuerzahl]="*"+links+"*"
_steuercode[_steuerzahl]=""
for x=1 to 50
if teile[x]<>"" then
val teile[x],y
zeichen=""
stradd zeichen,chr(y)
_steuercode[_steuerzahl]=_steuercode[_steuerzahl]+zeichen
else
x=51
endif
next
endif
rem Eigenschaften für Felder
if zeichen="!" then
_flags_anzahl=_flags_anzahl+1
_flags[_flags_anzahl]=rechts
_name[_flags_anzahl]=links
endif
rem Kalkulationen für Felder
if zeichen="$" then
_calc_anzahl=_calc_anzahl+1
_calc[_calc_anzahl]=rechts
_calcname[_calc_anzahl]=links
endif
if links="drucker" then
exist rechts,a
if a=1 then
loadarray rechts,druck_z,1,50,aa
for II=1 to aa
rem ** Steuercodes **
in druck_z[ii],"=",a
mid druck_z[ii],links,1,a-1
mid druck_z[ii],rechts,a+1,50
compress rechts,links
ltrim rechts,links
lcase links
replace rechts,'"',""
mid links,zeichen,1,1
if zeichen="#" then
clear teile,1,50
select rechts,44,teile,1,50
_steuerzahl=_steuerzahl+1
_steuer[_steuerzahl]="*"+links+"*"
_steuercode[_steuerzahl]=""
for x=1 to 50
if teile[x]<>"" then
val teile[x],y
zeichen=""
stradd zeichen,chr(y)
_steuercode[_steuerzahl]=_steuercode[_steuerzahl]+zeichen
else
x=51
endif
next
endif
next
endif
endif
rem Kopienzahl
if links="kopien" then
val rechts,_kopien
endif
rem Importdateien *********************************************
if links="import_body" then
_import_body=rechts
endif
if links="import_top" then
_import_top=rechts
endif
if links="import_bottom" then
_import_bottom=rechts
endif
if links="import_end" then
_import_body=rechts
endif
rem ** Datei **
if links="ausgabe" then
_ausgabe=rechts
endif
rem *** Leerzeile entfernen
if links="body_leerzeilen" then
_body_leerzeilen=rechts
endif
rem *** Trennzeile einfügen
if links="body_trennzeile" then
_body_trennzeile=rechts
endif
rem ** Startkey **
if links="startkey" then
_startkey=rechts
endif
rem ** Endkey **
if links="endkey" then
_endkey=rechts
endif
rem ** Seitenvorschub am Schluß **
if links="seitenvorschub" then
_seitenvorschub=rechts
endif
rem ** Indexfeld **
if links="index_feld" then
val rechts,wert
_index_feld=wert
endif
rem ** Vorschub **
if links="vorschub" then
val rechts,wert
_vorschub=wert
endif
rem ** Seitenlänge **
if links="seitenlen" then
val rechts,wert
_seitenlen=wert
endif
rem ** Linker Rand **
if links="rand" then
val rechts,wert
mid _rand,_rand,1,wert
endif
rem ** Masterdatenbank **
if links="masterdb" then
_masterdb=rechts
endif
rem ** Slavedatenbank **
if links="slavedb" then
_slavedb=rechts
endif
rem *** Auf/Absteigend der Slavedb
if links="aufsteigend" then
_aufsteigend=rechts
endif
rem ** Index **
if links="index" then
_index=rechts
endif
endif
endif
next
if flag=0 then
msgbox "Keinen Definitionsteil gefunden",0,a,""
end
endif
if _ausgabe="" then
msgbox "Keine Ausgabedatei angegeben",0,a,""
end
endif
rem Prüfen ob DTE-Datei vorhanden
exist "report.dte",a
if a=1 then
import "report.dte"
endif
rem Prüfen ob DTE-Datei vorhanden
exist "startkey.dte",a
if a=1 then
open 7,"startkey.dte","r"
jkflag=1
endif
#toprun
if jkflag=1 then
gets 7,zeile
select zeile,44,jkteile,1,2
compress zeile
if jkteile1="EOF" or zeile="" then
close 7
kill "startkey.dte"
end
else
_startkey=jkteile1
val jkteile2,_kopien
endif
endif
rem Masterdatenbank öffnen
if _masterdb<>"" then
iopen 1,_masterdb
iopen_index 1,_masterdb
iset 1,_index,expr
igetstruct 1,_master,_slave,_anzahldb1
select _master[_index_feld],44,tet,1,3
compress tet2
ltrim tet2
ucase tet2
if tet2="N" then
_vergleich_num=1
endif
endif
rem Falls Slavedatenbank vorhanden dann auch öffnen
if _slavedb<>"" then
iopen 2,_slavedb
iopen_index 2,_slavedb
iset 2,_index,expr
igetstruct 2,_master,_slave,_anzahldb2
select _master[_index_feld],44,tet,1,3
compress tet2
ltrim tet2
ucase tet2
if tet2="N" then
_vergleich_num=1
endif
def_window "rep_win",15,5, 55,7
def_border "rep_border"
def_titel "rep_titel","Meldung" ;"center"
def_prompt "rep_pr",5,1,"Datei : ",_datei," ---> ",_ausgabe
def_prompt "rep_pr2",5,2," "
def_prompt "rep_pr3",5,3," "
add_item "rep_win","rep_border","rep_titel","rep_pr","rep_pr2","rep_pr3"
win_paint "rep_win"
rem Ausgabedatei öffnen
kill _ausgabe
open 1,_ausgabe
for yy=1 to _kopien
clear _total,1,10
seite=0
istart 1,_master
iread 1,a,_startkey,_master
if a<>0 then
msgbox "Keinen entsprechenden Datensatz gefunden",0,a,""
iclose 1
end
endif
istart 2,_slave
iread 2,a,_startkey,_slave
if a<>0 then
msgbox "Keinen rel. Datensatz in Slave gefunden",0,a,""
_anzahldb2=0 : rem Keine weitere Feldprüfung
endif
endif
set_item "rep_pr2","Analysiere Report "
set_item "rep_pr3","TOP "
gosub #get_top
set_item "rep_pr3","BODY "
gosub #get_body
set_item "rep_pr3","BOTTOM "
gosub #get_bottom
set_item "rep_pr3","END "
gosub #get_end
set_item "rep_pr2","Druck... "
gosub #druck_top
gosub #druck_body
gosub #druck_bottom
gosub #druck_end
if _seitenvorschub="ja" or _kopien>0 then
puts 1,chr(12),
endif
next
close 1
if _masterdb<>"" then iclose 1 : endif
if _slavedb<>"" then iclose 2 : endif
if jkflag=0 then
event_on_item "rep_win","end"
endif
if _ausgabe="screen" then
call show_datei("screen")
endif
if jkflag=1 then
goto #toprun
endif
end
rem ********************* Ende ***************************
rem *******************************************************************************
rem Routine um den Kopf jeder Seite zu Drucken
rem *******************************************************************************
#druck_top
exist _import_top,a
if a=1 then
import _import_top
endif
seite=seite+1 : rem Seitenzahl erhöhen
form seite,seite$,0,1 : rem Seite in String
zz=0 : rem Anzahl der Zeilen auf Null setzen
rem 0. Vorschub falls angegeben
if _vorschub>0 then
for i=1 to _vorschub
puts 1,""
zz=zz+1
gosub #info
next
endif
rem 1. ** Ermittlung des Kopfteils **
for i=1 to _top_anzahl
tmpzeile=_top_zeilen[i]
call zeile_wandeln(tmpzeile,seite)
puts 1,tmpzeile
zz=zz+1
gosub #info
if zz>_seitenlen-_bottom_anzahl then
gosub #seite_neu
endif
next
return
#druck_body
a=0
#hhh
if _vergleich_num=0 then
while _slave[_index_feld]=_startkey and a<>3 and a<>4
gosub #druck_body2
wend
if _endkey<>"" then
while _slave[_index_feld]<=_endkey and a<>3 and a<>4
gosub #druck_body2
wend
endif
else
val _startkey,_ver1
val _slave[_index_feld],_ver2
while _ver1=_ver2 and a<>3 and a<>4
gosub #druck_body2
val _slave[_index_feld],_ver2
wend
if _endkey<>"" then
val _endkey,_ver1
val _slave[_index_feld],_ver2
while _ver2 <=_ver1
gosub #druck_body2
val _slave[_index_feld],_ver2
if a=3 or a=4 then
_ver2=1
_ver1=0
endif
wend
endif
endif
return
rem ********************************************************************
#druck_body2
exist _import_body,a
if a=1 then
import _import_body
endif
igetrec 2,_slave
rem 1. ** Druck Body **
for i=1 to _body_anzahl
tmpzeile=_body_zeilen[i]
call zeile_wandeln(tmpzeile,seite)
compress tmpzeile
if _body_leerzeilen="ja" then
puts 1,tmpzeile
zz=zz+1
gosub #info
rem if zz>_seitenlen-_bottom_anzahl then
rem gosub #seite_neu
rem endif
else
if tmpzeile<>"" then
puts 1,tmpzeile
zz=zz+1
gosub #info
rem if zz>_seitenlen-_bottom_anzahl then
rem gosub #seite_neu
rem endif
endif
endif
next
if zz>_seitenlen-_bottom_anzahl then
gosub #seite_neu
endif
rem Trennzeile druckem
if _body_trennzeile="ja" then
puts 1,""
zz=zz+1
gosub #info
if zz>_seitenlen-_bottom_anzahl then
gosub #seite_neu
endif
endif
if _aufsteigend="ja" then
inext 2,a,_slave
else
iprev 2,a,_slave
endif
return
#druck_bottom
exist _import_bottom,a
if a=1 then
import _import_bottom
endif
for i=1 to _bottom_anzahl
tmpzeile=_bottom_zeilen[i]
call zeile_wandeln(tmpzeile,seite)
puts 1,tmpzeile
zz=zz+1
gosub #info
next
return
#druck_end
exist _import_end,a
if a=1 then
import _import_end
endif
for i=1 to _end_anzahl
tmpzeile=_end_zeilen[i]
call zeile_wandeln(tmpzeile,seite)
puts 1,tmpzeile
zz=zz+1
gosub #info
next
return
#seite_neu
gosub #druck_bottom
puts 1,chr(12)
gosub #druck_top
return
rem *******************************************************************************
rem Routine um den Kopf zu ermitteln
rem *******************************************************************************
#get_top
_top_anzahl=0
flag=0
rem 1. ** Ermittlung des Kopfteils **
for i=1 to anzahl
tmpzeile=zeilen[i]
compress tmpzeile
if tmpzeile=".top" then flag=2 : endif
if tmpzeile=".bottom" or tmpzeile=".body" then flag=3 : i=anzahl+1 : endif
if flag=2 and tmpzeile<>".top" then
_top_anzahl=_top_anzahl+1
_top_zeilen[_top_anzahl]=tmpzeile
endif
next
return
rem *******************************************************************************_body
rem Routine um den Mittelteil jeder Seite zu ermitteln
rem *******************************************************************************
#get_body
_body_anzahl=0
flag=1
rem 1. ** Das erste Mal drucken wie gehabt **
for i=1 to anzahl
tmpzeile=zeilen[i]
compress tmpzeile
if tmpzeile=".body" then flag=2 : endif
if tmpzeile=".bottom" then flag=3 : i=anzahl+1 : endif
if flag=2 and tmpzeile<>".body" then
_body_anzahl=_body_anzahl+1
_body_zeilen[_body_anzahl]=tmpzeile
endif
next
return
#get_bottom
_bottom_anzahl=0
flag=1
for i=1 to anzahl
tmpzeile=zeilen[i]
compress tmpzeile
if tmpzeile=".bottom" then flag=2 : endif
if tmpzeile=".end" then flag=3 : i=anzahl+1 : endif
if flag=2 and tmpzeile<>".bottom" then
_bottom_anzahl=_bottom_anzahl+1
_bottom_zeilen[_bottom_anzahl]=tmpzeile
endif
next
return
#get_end
_end_anzahl=0
flag=1
for i=1 to anzahl
tmpzeile=zeilen[i]
compress tmpzeile
if tmpzeile=".end" then flag=2 : endif
if flag=2 and tmpzeile<>".end" then
_end_anzahl=_end_anzahl+1
_end_zeilen[_end_anzahl]=tmpzeile
endif
next
return
rem *******************************************************************************_body
modul zeile_wandeln(char tmpzeile,float seite)
deffloat a,i,x,y,flag
defstring zeichen,seite$,date$,aus$,text$
form seite,seite$,0,1
datum date$,3
dim aus,1,20
deffloat aus_anzahl
rem 1. Prüfen ob Leerzeile
if tmpzeile="" then
exitmod
else
rem 2. Prüfen ob Zeile ohne Steuercodes mit Text vorhanden ist
in tmpzeile,"*",a
if a=-1 then
tmpzeile=_rand+tmpzeile
exitmod
else
rem 3. Zeile enthält Steuercodes
rem 3a) Steuercodetabelle in entspr. Plätze einsetzen
in tmpzeile,"#",a
if a<>-1 then
for x=1 to _steuerzahl
replace tmpzeile,_steuer[x],_steuercode[x]
next
endif
len tmpzeile,y
rem Ermittlung aller Felder im Report -> speichern im Array AUS
aus$=""
for x=1 to y
mid tmpzeile,zeichen,x,1
if zeichen="*" and flag=0 then
flag=1
else
if zeichen="*" and flag=1 then
flag=0
aus_anzahl=aus_anzahl+1
aus[aus_anzahl]=aus$
aus$=""
endif
endif
if flag=1 then
aus$=aus$+zeichen
endif
next
rem Felder aus DB holen
for i=1 to aus_anzahl
call feld_holen(aus[i],tmpzeile)
next
rem 3d) Diverse Variable prüfen
replace tmpzeile,"*seite*",seite$
replace tmpzeile,"*datum*",date$
tmpzeile=_rand+tmpzeile
endif
endif
endmod
modul feld_holen( char zeile,char tmpzeile)
defstring zeichen,wert1,text,zeichen2,feldnamen,text$,text2$,total$,altzeile
defstring such,wert0
deffloat i,x,a,wert3,wert2,total,wert4
dim ttt,1,10
mid zeile,altzeile,2,100
zeile=zeile+"*"
mid zeile,wert1,2,1
mid zeile,zeichen,3,3
val zeichen,wert2
rem Intervall prüfen und falls kein Feld dann zurück
if wert1="a" then
if wert2<1 or wert2 >_anzahldb1 then
exitmod
endif
else
if wert1="b" then
if wert2<1 or wert2 >_anzahldb2 then
exitmod
endif
else
rem Berechnungen
rem _ = Nur anzeigen
rem + = Anzeigen und Berechnung im Def-Teil durchführen
rem & = Berechnung durchführen nicht anzeigen
if wert1="_" or wert1="&" or wert1="+" then
mid zeile,wert0,2,4
if wert0="_var" then
mid zeile,wert0,6,2
form wert0,zeichen2,0,1
feldnamen="!_var"+zeichen2
in zeile,"-",a
if a=-1 then
wert3=0
else
len zeile,wert3
endif
val zeichen2,a
total$=_var[a]
call eigenschaften(feldnamen,wert3,total$)
replace tmpzeile,zeile,total$
exitmod
endif
mid altzeile,wert1,1,1
if wert1="&" or wert1="+" then
mid altzeile,altzeile,2,100
endif
in zeile,"-",a
if a=-1 then
wert3=0
else
len zeile,wert3
in altzeile,"-",a
mid altzeile,altzeile,1,a-1
endif
if wert1="+" or wert1="&" then
such="$"+altzeile
find _calcname,1,_calc_anzahl,such,i
if i>0 then
eval _calc[i],total
mid _calcname[i],total$,2,100
&total$&=total
endif
endif
total=0
total$=""
eval altzeile,total
form total,total$,2,1
feldnamen="!"+altzeile
call eigenschaften(feldnamen,wert3,total$)
if wert1="&" then
replace tmpzeile,zeile,""
else
replace tmpzeile,zeile,total$
endif
exitmod
else
exitmod
endif
endif
endif
form wert2,zeichen2,0,1
feldnamen="!"+wert1+zeichen2
in zeile,"-",a
if a=-1 then
wert3=0
else
len zeile,wert3
endif
if wert1="a" then
rem 3b) DB-Felder prüfen und einsetzen MASTER-DB
igetrec 1,_master
else
rem 3c) In der Slave-DB wenn vorhanden
igetrec 2,_master
endif
compress _master[wert2]
ltrim _master[wert2]
if wert3<>0 then
mid _master[wert2],text,1,wert3
set wert3,text
rem Eigenschaften prüfen
call eigenschaften(feldnamen,wert3,text)
else
text=_master[wert2]
endif
replace tmpzeile,zeile,text
endmod
rem WERT3 - > die Länge des Strings
modul eigenschaften(char feldnamen,float wert3,char text)
deffloat a,i
dim teile,1,10
find _name,1,_flags_anzahl,feldnamen,a
if a>0 then
clear teile,1,10
select _flags[a],44,teile,1,10
compress2 teile,1,10
i=1
while teile[i]<>"" then
if teile[i]="ucase" then ucase text : endif
if teile[i]="lcase" then lcase text : endif
if teile[i]="rset" then
compress text
rset wert3,text
endif
if teile[i]="lset" then
ltrim text
compress text
set wert3,text
endif
if teile[i]="dez0" then
form text,text,0,wert3
endif
if teile[i]="dez1" then
form text,text,1,wert3
endif
if teile[i]="dez2" then
form text,text,2,wert3
endif
if teile[i]="dez3" then
form text,text,3,wert3
endif
i=i+1
wend
endif
endmod
#info
form zz,zz$,0,1
zz$="Seite : "+seite$+" Zeile : "+zz$
set_item "rep_pr3",zz$
return
MODUL show_datei(char datei)
defstring objekt,id$,i$,zeile
deffloat ok,i,taste
def_window "win_info",0,2, 91,18 ;"modal"
def_border "win_info_border"
def_titel "win_info_titel","Ausgabe" ;"center"
def_max_button "win_max_b"
add_item "win_info","win_info_border","win_max_b","win_info_titel"
DEF_TOOLBAR "tool_info",0,0,0,0;"region off","border"
DEF_SCROLLBAR "scroll_info",1,0,0,0,0
DEF_BUTTON "PushButton1",3,1,15,"","Quit";""
DEF_BUTTON "PushButton2",13,1,15,"","Druck LPT1";""
DEF_BUTTON "PushButton3",23,1,15,"","Druck LPT2";""
DEF_LIST "text_info",0,1,0,87,15,0,0 ;"border","c8","select off"
add_item "text_info","scroll_info"
add_item "tool_info","PushButton1","PushButton2","PushButton3"
ADD_ITEM "win_info","tool_info","text_info"
i=1
open 11,datei,"r"
gets 11,zeile
gets 11,zeile
while zeile<>"EOF"
form i,i$,0,1
id$="text"+i$
def_string id$,1,0,80,zeile
add_item "text_info",id$
rem event_on_item "text_info","redisplay"
gets 11,zeile
i=i+1
wend
close 11
win_paint "win_info"
while i<>1000
win_ev i
get_item_pos objekt,taste
if taste=13 and objekt="PushButton1" then
kill datei
i=1000
endif
if taste=13 and objekt="PushButton2" then
call info_druck(datei,"lpt1")
i=1000
endif
if taste=13 and objekt="PushButton3" then
call info_druck(datei,"lpt2")
i=1000
endif
wend
event_on_item "win_info","end"
ENDMOD
MODUL info_druck(char datei_send,char datei_empf)
defstring zeile
call tmp_fenster(1)
open 11,datei_send,"r"
open 12,datei_empf
gets 11,zeile
while zeile <> "EOF"
puts 12,zeile
gets 11,zeile
wend
close 11
close 12
call tmp_fenster(0)
kill datei_send
ENDMOD
MODUL tmp_fenster(float flag)
if flag=1 then
def_window "msg_be",30,7,26,6 ;"move off","modal"
def_border "msg_border_be"
def_titel "msg_titel_be","Meldung" ;"center"
def_prompt "msg_pr1_be",1,1,"Daten werden gedruckt"
def_prompt "msg_pr2_be",5,2,"Bitte warten !"
add_item "msg_be",..
"msg_border_be",..
"msg_titel_be",..
"msg_pr1_be",..
"msg_pr2_be"
win_paint "msg_be"
else
event_on_item "msg_be","end"
endif
ENDMOD