1. Help on converting to EUPHORIA
- Posted by Karlheinz Nester <Karlheinz_Nester at COMPUSERVE.COM> Jun 22, 1998
- 651 views
To : Robert Craig (RDS) or any more expirienced euphorian interested in conversions Problem : Converting Unicomal programs to Euphoria 2.0 I'm running into a small problem.Unicomal is a OOP language,but I'm surprised how elegant it is to circumvent the OOP stuff. Only the concatination of printout X1 with X2 in EU (like XA,XB in Comal)= printf(1," %-1s %5.2f",{m[z][con]),f[4]/1000}) (concat X1 and X2) is not possible,both return values are always zero,seperate values are OK= =2E Am I making false reasoning ??,may the EU version be improved ??. It's a tiny test program,so please don't cut it in pieces. I would appreciate any tip,could be "positive critism". TIA Karlheinz ----------------------------------------------------------------------- // save "asymot" // Unicomal Version 19.01.90 PAGE USE system STRUC motor DIM p2, u, i, pf, nn, fn, con$ OF 1 FUNC q RETURN SQR(3)*u*i*SIN(ACS(pf/100)) // reactive power ENDFUNC q FUNC m RETURN (p2*1000)/(0.1045*nn) // nominal torque ENDFUNC m FUNC s RETURN SQR(3)*u*i // apparent power ENDFUNC s FUNC p1 RETURN SQR(3)*u*i*pf // active power ENDFUNC p1 FUNC eff RETURN (p2/p1) // efficiency ENDFUNC eff ENDSTRUC motor quantity:=3D6 DIM ac_motor(6). OF motor FOR no:=3D1 TO quantity DO READ ac_motor(no). // Nameplate data // P2(kW),U(Volt),I(A),pf(%),n(RPM),f(Hz),connection type (delta/wye) DATA 3,380,6.9,84,960,50,"w" DATA 4,380,8.8,84,960,50,"w" DATA 5.5,380,11.5,85,960,50,"w" DATA 7.5,380,15.6,85,960,50,"w" DATA 11,380,22.5,86,960,50,"w" DATA 15,380,30,86,960,50,"w" PRINT AT 2,2: "3-phase Induction motors" PRINT AT 4,2: " P2 nn Un fn pf I con Q Tn = = S eff" PRINT AT 5,2: " kW RPM V Hz % A kvar MN = = kVA %" PRINT AT 6,2: FOR no:=3D1 TO quantity DO PRINT USING "##.## ####.## ": ac_motor(no).p2,ac_motor(no).nn; PRINT USING "###.## ## Hz ": ac_motor(no).u,ac_motor(no).fn; PRINT USING "##.## ##.## ": ac_motor(no).pf,ac_motor(no).i; PRINT USING ">> ##.## ": ac_motor(no).con$,ac_motor(no).q/1000; <-- = XA PRINT USING "####.## ##.##": ac_motor(no).m,ac_motor(no).s/1000; <-- = XB PRINT USING "##.## ": ac_motor(no).eff*100000 ENDFOR no -- asymot.ex 21.6.98 Unicomal 3.11 ---> Euphoria 2.0 -------------------------------------------------------------------------= - sequence f,m integer quantity constant P2 =3D 1,U =3D 2,I =3D 3,pf =3D 4,n =3D 5,fn =3D 6,con =3D 7 -------------------------------------------------------------------------= -- clear_screen() -------------------------------------------------------------------------= -- function acs(atom c) -- arccosinus in radians return 1.5708 - 2 * arctan(c/(1 + sqrt(1 - c * c))) end function -------------------------------------------------------------------------= -- m=3D{ -- nameplate data {3 ,380,6.9 ,0.84,960,50,"w"}, {4 ,380,8.8 ,0.84,960,50,"w"}, {5.5,380,11.5,0.85,960,50,"w"}, {7.5,380,15.6,0.85,960,50,"w"}, {11 ,380,22.5,0.86,960,50,"w"}, {15 ,380,30 ,0.86,960,50,"w"} } puts(1," 3-phase Induction motors \n") puts(1," P2 nn Un fn pf I con Q T S eff\n")= puts(1," kW RPM V Hz % A kvar Nm kVA %\n\n"= ) quantity =3D 6 for z =3D 1 to quantity do f=3D{ -- formulas {sqrt(3) * m[z][U] * m[z][I] * m[z][pf]}, -- P1 {sqrt(3) * m[z][U] * m[z][I]}, -- apparent powe= r {m[z][P2] /(sqrt(3) * m[z][U] * m[z][I] * m[z][pf])}, -- efficiency {sqrt(3) * m[z][U] * m[z][I] * sin(acs(m[z][pf]))}, -- reactive powe= r {(m[z][P2] * 1000) / (0.1045 * m[z][n])} -- nominal torqu= e } printf(1," %5.2f %-4.0f ",{m[z][P2],m[z][n]}) -- P2 , nn printf(1," %-3.0f %2.0f ",{m[z][U],m[z][fn]}) -- Un , fn printf(1," %-2.2f %6.2f ",{m[z][pf],m[z][I]}) -- pf , I printf(1," %-1s ",m[z][con]) -- con <-- X1 printf(1," %5.2f ",f[4]/1000) -- Q <-- X2 printf(1," %6.2f ",f[5]) -- mn <-- X3 printf(1," %5.2f ",f[2]/1000) -- S <-- X4 printf(1," %-3.2f\n",f[3] * 100000) -- eff end for -------------------------------------------------------------------------= -- =