-- stack: in -- format: 10 (HyperCard 2) -- flags: 0x1000 (none) -- protect password hash: 0 -- maximum user level: 5 (scripting) -- window: Rect(x1=112, y1=113, x2=528, y2=353) -- screen: Rect(x1=0, y1=0, x2=640, y2=480) -- card dimensions: w=416 h=240 -- scroll: x=0 y=0 -- background count: 1 -- first background id: 2754 -- card count: 1 -- first card id: 3602 -- list block id: 2156 -- print block id: 0 -- font table block id: 3385 -- style table block id: 3183 -- free block count: 5 -- free size: 5728 bytes -- total size: 16384 bytes -- stack block size: 6656 bytes -- created by hypercard version: 0x02418000 -- compacted by hypercard version: 0x02418000 -- modified by hypercard version: 0x02418000 -- opened by hypercard version: 0x02418000 -- patterns[0]: 0x0000000000000000 -- patterns[1]: 0x8000000008000000 -- patterns[2]: 0x8800220088002200 -- patterns[3]: 0x8888222288882222 -- patterns[4]: 0x88AA22AA88AA22AA -- patterns[5]: 0xCCAA33AACCAA33AA -- patterns[6]: 0xEEAABBAAEEAABBAA -- patterns[7]: 0xEEBBBBEEEEBBBBEE -- patterns[8]: 0xFFBBFFEEFFBBFFEE -- patterns[9]: 0xFFBBFFFFFFBBFFFF -- patterns[10]: 0x8010022001084004 -- patterns[11]: 0xFFFFFFFFFFFFFFFF -- patterns[12]: 0x8822882288228822 -- patterns[13]: 0x1122448811224488 -- patterns[14]: 0xC4800C6843023026 -- patterns[15]: 0xB130031BD8C00C8D -- patterns[16]: 0xAA00AA00AA00AA00 -- patterns[17]: 0x8822552288225522 -- patterns[18]: 0x8855225588552255 -- patterns[19]: 0x77DD77DD77DD77DD -- patterns[20]: 0x8000000000000000 -- patterns[21]: 0xAA55AA55AA55AA55 -- patterns[22]: 0x038448300C020101 -- patterns[23]: 0x8244394482010101 -- patterns[24]: 0x8814224188412214 -- patterns[25]: 0x8080413E080814E3 -- patterns[26]: 0x22048C7422179810 -- patterns[27]: 0xBE808808EB088880 -- patterns[28]: 0x25C8328964244C92 -- patterns[29]: 0xA29C41BE2AC914EB -- patterns[30]: 0x40A00000040A0000 -- patterns[31]: 0x8040200002040800 -- patterns[32]: 0xAA00800088008000 -- patterns[33]: 0xFF80808080808080 -- patterns[34]: 0x081C22C180010204 -- patterns[35]: 0xFF808080FF080808 -- patterns[36]: 0xF87422478F172271 -- patterns[37]: 0xBF00BFBFB0B0B0B0 -- patterns[38]: 0xFF7FBE5DA2418000 -- patterns[39]: 0xFAF5FAF5A050A050 -- checksum: 0xDDA1A3F7 ----- HyperTalk script ----- function complexNumbers a,b,o,c,d if o = "+" then return (a+c)&(the itemdelimiter)&(b+d) if o = "-" then return (a-c)&(the itemdelimiter)&(b-d) if o = "*" then return ((a*c)-(b*d))&(the itemdelimiter)&((b*c)+(c*d)) if o = "/" then return (((a*c)/((c^2)+(d^2)))+((b*d)/((c^2)+(d^2))))&(the itemdelimiter)&(((b*c)/((c^2)+(d^2)))+((c*d)/(((c^2)+(d^2))^2))) if o = "\" or h = "div" then return (((a*c)DIV((c^2)+(d^2)))+((b*d)DIV((c^2)+(d^2))))&(the itemdelimiter)&(((b*c)DIV((c^2)+(d^2)))+((c*d)DIV(((c^2)+(d^2))^2))) if o = "mod" then return (((a*c)MOD((c^2)+(d^2)))+((b*d)MOD((c^2)+(d^2))))&(the itemdelimiter)&(((b*c)MOD((c^2)+(d^2)))+((c*d)MOD(((c^2)+(d^2))^2))) if o = "^" then return exp((c*ln(sqrt((a^2)+(b^2))))-(d*theta(a,b)))*cos((d*ln(sqrt((a^2)+(b^2))))+(c*theta(a,b)))&(the itemdelimiter)&exp((c*ln(sqrt((a^2)+(b^2))))-(d*theta(a,b)))*sin((d*ln(sqrt((a^2)+(b^2))))+(c*theta(a,b))) if o = "√" or h = "root" then return complexNumbers(a,b,"^",c/((c^2)+(d^2)),d/((c^2)+(d^2))) if a = "|" or a = "abs" then return sqrt((b^2)+(o^2))&(the itemdelimiter)&"0" if a = "sin" then return sin(b)*cosh(o)&(the itemdelimiter)&cos(b)*sinh(o) if a = "cos" then return cos(b)*cosh(o)&(the itemdelimiter)&sin(b)*sinh(o) if a = "tan" then return complexnumbers(sin(b)*cosh(o),cos(b)*sinh(o),"/",cos(b)*cosh(o),sin(b)*sinh(o)) if a = "atan" then return ((theta(1-o,b)/2)-(theta(1+o,-b)/2))&(the itemdelimiter)&(ln(((b^2)+((o+1)^2))/((b^2)+((o-1)^2)))/4) if a = "/" then return (b/((b^2)+(o^2)))&(the itemdelimiter)&(o/((b^2)+(o^2))) if a = "ln" or a = "log" or a = "loge" then if c is a number then return ln(abs(b))&(the itemdelimiter)&(theta(b,o)+(2*pi*c)) return ln(abs(b))&(the itemdelimiter)&theta(b,o) end if if a = "log2" then return complexNumbers(item 1 of complexNumbers("ln",b,o,c),item 2 of complexNumbers("ln",b,o,c),"/",ln(2),0) if a = "log10" then return complexNumbers(item 1 of complexNumbers("ln",b,o,c),item 2 of complexNumbers("ln",b,o,c),"/",ln(10),0) if a = "exp" then return (exp(b)*cos(o))&(the itemdelimiter)&(cos(o)*sin(o)) if a = "√" or a = "sqrt" or a = "sqr" then return complexnumbers(b,o,"^",0.5,0) if a = "sgn" then if b < 0 then put "-1" into ta if b > 0 then put "1" into ta if b = 0 then put "0" into ta put (the itemdelimiter) after ta if o > 0 then put "1" after ta if o < 0 then put "-1" after ta if o = 0 then put "0" after ta return ta end if if a = "P>R" then return (b*cos(o))&(the itemdelimiter)&(b*sin(o)) if a = "R>P" then return sqrt((b^2)+(o^2))&(the itemdelimiter)&theta(b,o) if a = "BC" or a = "BaseConv" or a = "BaseConvert" or a = "BaseConvertReal" then put baseconvertreal(b,c,d) into ta put (the itemdelimiter) after ta put baseconvertreal(o,c,d) after ta return ta end if return "Error: Unsupported operation." end complexNumbers function cn l,m,n,o,p return complexNumbers(l,m,n,o,p) end cn function cpxAdd a,b,c,d return cn(a,b,"+",c,d) end cpxAdd function cpxSub a,b,c,d return cn(a,b,"-",c,d) end cpxSub function cpxMul a,b,c,d return cn(a,b,"*",c,d) end cpxMul function cpxDiv a,b,c,d return cn(a,b,"/",c,d) end cpxDiv function cpxPower a,b,c,d return cn(a,b,"^",c,d) end cpxPower function cpxLog a,b,v return cn("ln",a,b,v) end cpxlog function cpxExp a,b return cn("exp",a,b) end cpxExp function cpxSin a,b return cn("sin",a,b) end cpxSin function cpxCos a,b return cn("cos",a,b) end cpxCos function cpxAbs a,b return cn("|",a,b) end cpxAbs function cpxRecip a,b return cn("/",a,b) end cpxRecip function cpxSgn a,b return cn("sgn",a,b) end cpxSgn function cpxIntDiv a,b,c,d return cn(a,b,"\",c,d) end cpxIntDiv function cpxMod a,b,c,d return cn(a,b,"mod",c,d) end cpxMod function cpxSqrt a,b return cn("sqrt",a,b) end cpxSqrt function cpxRoot a,b,c,d return cn(a,b,"√",c,d) end cpxRoot function cpxTan a,b return cn("tan",a,b) end cpxTan function cpxstrtoval x put the itemdelimiter into z if x is a number then return (x*1)&z&"0" if the last char of x <> "i" then return "ERROR: Expected complex number here." if "+" is not in x and "-" is not in x then delete last char of x return "0"&z&(x*1) end if if "+" is in x and "-+" is not in x then set the itemdelimiter to "+" delete last char of x put ((item 1 of x)*1)&z&((item 2 of x)*1) into y set the itemdelimiter to z return y end if if the first char of x is "-" and "+-" is not in x then set the itemdelimiter to "-" delete last char of x put ((item 2 of x)*-1)&z&-((item 3 of x)*1) into y set the itemdelimiter to z return y end if if "-" is in x and "+-" is not in x then set the itemdelimiter to "-" delete last char of x put ((item 1 of x)*1)&z&-((item 2 of x)*1) into y set the itemdelimiter to z return y end if end cpxstrtoval function cpxvaltostr a,b put a into x if b<0 then put b after x if b=0 or b>0 then put "+" & b after x put "i" after x return x end cpxvaltostr