home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Spezial
/
SPEZIAL2_97.zip
/
SPEZIAL2_97.iso
/
ANWEND
/
WPS
/
PMMEAL10
/
convert.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-07-28
|
5KB
|
175 lines
/* */
von_dir=".\"
nach_dir=".\"
if arg(1,"E") then von_dir=arg(1)
if arg(2,"E") then nach_dir=arg(2)
if right(von_dir,1)<>"\" & right(von_dir,1)<>":" then von_dir=von_dir"\"
if right(nach_dir,1)<>"\" & right(nach_dir,1)<>":" then nach_dir=nach_dir"\"
numeric digits 15
such.titel.0=0
such.titel="ff"x
such.category.0=0
ok=stream(von_dir"Ingred.mme","C","Open Read")
ok=stream(von_dir"index.mme","C","Open Read")
ok=stream(von_dir"direct.mme","C","Open Read")
indexlg=stream(von_dir"index.mme","C","Query Size")/634-1
indexnr=0; directnr=0;
say "Konvertiere Daten MEALMASTER --> PMMEAL"
do n=1 to indexlg
call charout "con",n"/"indexlg"0d"x
call readindex n,1,1
say meal.titel
such.titel=such.titel||meal.titel||"ff"x||n||"ff"x
x=left(meal.titel,60)
do m=1 to 5
x=x||left(meal.category.m,11)
if meal.category.m<>"" then do
cat=translate(meal.category.m)
if such.cat<>"SUCH."CAT then do
k=such.cat
end; else do
k=such.category.0+1
such.cat=k
such.category.k=meal.category.m
such.category.k.0=0
such.category.0=k
end
i=such.category.k.0+1
such.category.k.i=n
such.category.k.0=i
end
end
x=x||left(meal.anzyield,4)||left(meal.yield,10)
x=x||meal.suchstring
do m=1 to meal.ingred.0
indexnr=indexnr+1
meal.anz.m=makemenge(meal.anz.m)
if meal.anz.m=3000000 then meal.anz.m="-------"
call lineout nach_dir"PMMZUTAT.DAT",left(meal.anz.m,7)left(meal.einheit.m,2)left(meal.ingred.m,28)
x=x||d2c(indexnr,3)
end
x=x||left("",(100-(meal.ingred.0+meal.direct.0))*3,"0"x)
do m=meal.direct.0 to 1 by -1
directnr=directnr+1
call lineout nach_dir"PMMTEXTE.DAT",left(meal.direct.m,75)
x=x||d2c(directnr,3)
end
x=x||" 0 0 "
call charout nach_dir"PMMINDEX.DAT",x
end
call lineout nach_dir"PMMTITEL.IDX",indexlg
call lineout nach_dir"PMMTITEL.IDX",such.titel
call lineout nach_dir"PMMCATEG.IDX",indexlg
do n=1 to such.category.0
x=such.category.n
do m=1 to such.category.n.0
x=x";"such.category.n.m
end
call lineout nach_dir"PMMCATEG.IDX",x
end
ok=stream(von_dir"Ingred.mme","C","close")
ok=stream(von_dir"index.mme","C","close")
ok=stream(von_dir"direct.mme","C","close")
ok=stream(nach_dir"PMMtitel.idx","C","close")
ok=stream(nach_dir"PMMcateg.idx","C","close")
ok=stream(nach_dir"PMMzutat.dat","C","close")
ok=stream(nach_dir"PMMtexte.dat","C","close")
ok=stream(nach_dir"PMMindex.dat","C","close")
signal ende
readindex: procedure expose meal. von_dir
p=arg(1)
suchingred=arg(2,"E")
suchdirect=arg(3,"E")
index=charin(von_dir"index.mme",1+634*p,634)
lg=c2d(substr(index,1,1))
meal.nr=p
meal.titel=substr(index,2,lg)
do n=1 to 5
m=62+(n-1)*12
lg=c2d(substr(index,m,1))
meal.category.n=substr(index,m+1,lg)
end
meal.anzyield=c2d(reverse(substr(index,122,2)))
lg=c2d(substr(index,124,1))
meal.Yield=substr(index,125,lg)
if suchingred then do
i=0; d=0;
meal.direct.0=0;
meal.suchstring=substr(index,135,100)
do n=135 to 234
x=substr(index,n,1)
select
when x="I" then do
i=i+1
ix=c2d(reverse(substr(index,235+(n-135)*4,4)))
x=charin(von_dir"Ingred.mme",1+ix*38,38)
if suchdirect then do
lg=c2d(substr(x,7,1))
meal.einheit.i=substr(x,8,lg)
meal.anz.i=makereal(substr(x,1,6))
end
lg=c2d(substr(x,10,1))
meal.ingred.i=substr(x,11,lg)
end
when x="X" & \suchdirect then n=999
when x="D" & suchdirect then do
if d=0 then meal.direct.0=235-n
d=235-n
ix=c2d(reverse(substr(index,235+(n-135)*4,4)))
x=charin(von_dir"direct.mme",1+ix*76,76)
lg=c2d(substr(x,1,1))
meal.direct.d=substr(x,2,lg)
end
otherwise nop
end
end
meal.ingred.0=i
end
return
makereal: procedure
real=arg(1)
teiler=1099511627775
breal=x2b(c2x(reverse(real)))
minus=left(breal,1)
expo=x2d(b2x(right(breal,7)))
mant=x2d(b2x(substr(breal,2,39)))
test=substr(breal,41,1)
e=1
if expo=0 & \test then e=0
if \test & expo>0 then
do m=1 to 128-expo
e=e/2
end
else
do m=1 to expo
e=e*2
end
wert=format(e*(0.5+mant/teiler),,4)
return wert
makemenge: procedure
wert=arg(1)
wert1=trunc(wert)
wert2=wert-wert1
if format(wert2,,5)=0 then
wert2="";
else do
div=1
divi=div/wert2
do while right(format(divi,,3),3)<>"000"
div=div+1
divi=div/wert2
end
wert2=" "div"/"format(divi,,0)
end
if wert1=0 then wert1=""
wert=right(wert1||wert2,7)
return wert
ende: