rem Euro Calculator V1.3 rem By Tommy Sools (tommy@sools.com) option decimalsep,. option fieldsep,| option scale,96 directory change,@path(%0) %%vdsinet = option errortrap,skip external vdsinet.dll,Public Freeware Key|90257236 %%vdsinet = 1 :skip option errortrap rem EUR = European euro rem ATS = Austrian schilling rem BEF = Belgian franc rem DEM = Deutsche Mark rem ESP = Spanish peseta rem FIM = Finnish markka rem FRF = French franc rem GRD = Greek drachma rem IEP = Irish pound rem ITL = Italian lira rem LUF = Luxembourg franc rem NLG = Dutch guilder rem PTE = Portuguese escudo rem the following currencies (marked with a star) are subjected to changes; rem look at http://www.ecb.int/home/eurofxref.htm: rem USD = United States dollar rem JPY = Japanese yen rem DKK = Danish krone rem GBP = Pound sterling rem SEK = Swedish krona rem CHF = Swiss franc rem ISK = Icelandic krona rem NOK = Norwegian krone rem BGN = Bulgarian lev rem CYP = Cyprus pound rem CZK = Czech koruna rem EEK = Estonian kroon rem HUF = Hungarian forint rem LTL = Lithuanian litas rem LVL = Latvian lat rem MTL = Maltese lira rem PLN = Polish zloty rem ROL = Romanian leu rem SIT = Slovenian tolar rem SKK = Slovakian koruna rem TRL = Turkish lira rem AUD = Australian dollar rem CAD = Canadian dollar rem HKD = Hong Kong dollar rem NZD = New Zealand dollar rem SGD = Singaporean dollar rem KRW = South Korean won rem ZAR = South African rand %%file = .\@name(%0).dat list create,1 if @file(%%file) list loadfile,1,%%file else list loadtext,1 "* AUD|1.7111 "* BGN|1.9466 "* CAD|1.3531 "* CHF|1.5078 "* CYP|0.57409 "* CZK|33.878 "* DKK|7.4485 "* EEK|15.6466 "* GBP|0.61180 "* HKD|6.8451 "* HUF|249.20 "* ISK|88.54 "* JPY|108.36 "* KRW|1145.88 "* LTL|3.5113 "* LVL|0.5521 "* MTL|0.3994 "* NOK|8.0170 "* NZD|2.1239 "* PLN|3.6990 "* ROL|25825 "* SEK|9.2631 "* SGD|1.6006 "* SIT|218.9110 "* SKK|42.739 "* TRL|1150767 "* USD|0.8776 "* ZAR|7.2418 "ATS|13.7603 "BEF|40.3399 "DEM|1.95583 "ESP|166.386 "EUR|1 "FIM|5.94573 "FRF|6.55957 "GRD|340.750 "IEP|0.787564 "ITL|1936.27 "LUF|40.3399 "NLG|2.20371 "PTE|200.482 end rem auto-update currencies if %%vdsinet dialog CREATE,Please wait...,-1,0,266,49,NOSYS dialog ADD,STYLE,sCenter,,6,C,BACKGROUND,FOREGROUND dialog ADD,TEXT,tNotice,16,8,248,16,Auto-updating...,SCENTER dialog SHOW option errortrap,skip2 net http,get,http://www.ecb.int/home/eurofxref.htm list create,2 repeat %a = @net(http) if @not(@both(@equal(%a,@cr()),@equal(@len(%A),1))) list add,2,%a end until @both(@equal(%a,@cr()),@equal(@len(%A),1)) list seek,1,0 repeat parse "%a;",@item(1) %a = @substr(%a,3,@len(%a)) list seek,2,0 %x = @match(2,<td align=@chr(34)center@chr(34)>%a</td>) if %x %x = @next(2) %x = @next(2) %b = @item(2) %c = @pos(>,%b) %d = @pos(</,%b) list put,1,* %a|@substr(@item(2),@succ(%c),@pred(%d)) end until @not(@equal(@substr(@next(1),1,1),*)) list close,2 :skip2 option errortrap dialog hide end list savefile,1,%%file %%memory = 0 dialog CREATE,Euro Calculator,-1,0,273,212,ONTOP dialog ADD,STYLE,sValue,,6,,BLACK,CYAN dialog ADD,STYLE,sMemory,,6,C,BACKGROUND,LTBLUE dialog ADD,STYLE,sWingdings,Wingdings,8,BC,BACKGROUND,FOREGROUND dialog ADD,STYLE,sSource,,6,L,BACKGROUND,FOREGROUND dialog ADD,STYLE,sDest,,6,R,BACKGROUND,FOREGROUND dialog ADD,EDIT,eValue,8,8,256,18,0,,READONLY,SVALUE dialog ADD,BUTTON,b7,40,8,24,14,&7 dialog ADD,BUTTON,b8,40,40,24,14,&8 dialog ADD,BUTTON,b9,40,72,24,14,&9 dialog ADD,BUTTON,b4,64,8,24,14,&4 dialog ADD,BUTTON,b5,64,40,24,14,&5 dialog ADD,BUTTON,b6,64,72,24,14,&6 dialog ADD,BUTTON,b1,88,8,24,14,&1 dialog ADD,BUTTON,b2,88,40,24,14,&2 dialog ADD,BUTTON,b3,88,72,24,14,&3 dialog ADD,BUTTON,b0,112,8,24,14,&0 dialog ADD,BUTTON,bDecimal,112,40,24,14,&. dialog ADD,BUTTON,bNegative,112,72,24,14,-/+ dialog ADD,BUTTON,bC,40,104,24,14,&C dialog ADD,BUTTON,bResult,64,104,24,14,=,,default dialog ADD,BUTTON,bAdd,40,144,24,14,&+ dialog ADD,BUTTON,bDiff,40,176,24,14,&- dialog ADD,BUTTON,bProd,40,208,24,14,&* dialog ADD,BUTTON,bDiv,40,240,24,14,&/ dialog ADD,BUTTON,bMod,64,144,24,14,&% dialog ADD,BUTTON,bMoney,64,176,24,14,&$ dialog ADD,BUTTON,bMAdd,88,144,24,14,M+ dialog ADD,BUTTON,bMS,88,176,24,14,MS dialog ADD,BUTTON,bMR,88,208,24,14,&MR dialog ADD,BUTTON,bMC,88,240,24,14,MC dialog ADD,TEXT,tMemory,112,144,,,Memory: dialog ADD,TEXT,tMemory2,112,190,50,,%%memory,,sMemory dialog ADD,TEXT,tSource,144,8,72,16,Source:,,SSOURCE dialog ADD,TEXT,tDest,144,192,72,16,Destination:,,SDEST dialog ADD,COMBO,cSource,168,8,120,21,cSource,,SORTED,LIST dialog ADD,COMBO,cDest,168,144,120,21,cDest,,SORTED,LIST dialog ADD,TEXT,tNotice,194,10,,,* non-euro currency dialog SHOW dialog focus,bResult list seek,1,0 repeat parse "%%item;",@next(1) list add,cSource,%%item until @equal(@index(1),@count(1)) %x = @match(cSource,* USD) list assign,cDest,cSource %x = @match(cDest,EUR) %%reset = option errortrap,error :evloop wait event %e = @event() if @not(@numeric(@dlgtext(eValue))@numeric(@dlgtext(eValue)0)) dialog set,eValue,0 end if @equal(@substr(%e,1,1),b) %e = @strdel(%e,1,1) %e = @substr(%e,1,-6) if @numeric(%e) if %%reset %%reset = dialog set,eValue,0 end if @zero(@dlgtext(eValue)) dialog set,eValue,%e else dialog set,eValue,@dlgtext(eValue)%e end goto evloop end if @equal(@substr(%e,1,3),dir) if @equal(@strdel(%e,1,3),1) %%source = cDest %%dest = cSource else %%source = cSource %%dest = cDest end list seek,1,0 %x = @match(1,@dlgtext(%%source)) parse ";%%rate",@item(1) %%eur = @fdiv(@dlgtext(eValue),%%rate) list seek,1,0 %x = @match(1,@dlgtext(%%dest)) parse ";%%rate",@item(1) dialog set,eValue,@fmul(%%EUR,%%rate) %%reset = 1 goto evloop end if @equal(%e,C) dialog set,eValue,0 %%value1 = %%reset = goto evloop end if @equal(%e,negative) if @not(@zero(@dlgtext(eValue))) if @equal(@substr(@dlgtext(eValue),1,1),-) dialog set,eValue,@strdel(@dlgtext(eValue),1,1) else dialog set,eValue,-@dlgtext(eValue) end end goto evloop end if @equal(%e,add)@equal(%e,diff)@equal(%e,prod)@equal(%e,div)@equal(%e,mod) if %%operation gosub calc end %%value1 = @dlgtext(eValue) %%operation = %e %%reset = 1 goto evloop end if @equal(%e,result) if %%operation gosub calc end %%reset = 1 goto evloop end if @equal(%e,money) dialog set,eValue,@format(@dlgtext(eValue),.2) %%reset = 1 goto evloop end if @equal(%e,decimal) if @numeric(@dlgtext(eValue).0) dialog set,eValue,@dlgtext(eValue). end goto evloop end if @equal(%e,MAdd) if @both(@not(@numeric(@dlgtext(eValue))),@numeric(@dlgtext(eValue)0)) dialog set,eValue,@dlgtext(eValue)0 end %%memory = @fadd(%%memory,@dlgtext(eValue)) dialog set,tMemory2,%%memory %%reset = 1 goto evloop end if @equal(%e,MS) if @both(@not(@numeric(@dlgtext(eValue))),@numeric(@dlgtext(eValue)0)) dialog set,eValue,@dlgtext(eValue)0 end %%memory = @dlgtext(eValue) dialog set,tMemory2,%%memory %%reset = 1 goto evloop end if @equal(%e,MR) dialog set,eValue,%%memory %%reset = 1 goto evloop end if @equal(%e,MC) %%memory = 0 dialog set,tMemory2,%%memory goto evloop end warn Unexpected error! goto evloop else goto %e end :calc if @both(@not(@numeric(@dlgtext(eValue))),@numeric(@dlgtext(eValue)0)) dialog set,eValue,@dlgtext(eValue)0 end %%value2 = @dlgtext(eValue) gosub calc2 dialog set,eValue,%%value %%operation = exit :calc2 if @equal(%%operation,add) %%value = @fadd(%%value1,%%value2) exit end if @equal(%%operation,diff) %%value = @fsub(%%value1,%%value2) exit end if @equal(%%operation,prod) %%value = @fmul(%%value1,%%value2) exit end if @equal(%%operation,div) if @zero(%%value2) %%value = Can't divide by zero else %%value = @fdiv(%%value1,%%value2) end exit end if @equal(%%operation,mod) if @zero(%%value2) %%value = Can't divide by zero else rem @MOD() doesn't support decimals %%value = @fdiv(%%value1,%%value2) rem truncate the value %%pos = @pos(.,%%value) if @greater(%%pos,0) %%value = @strdel(%%value,%%pos,@len(%%value)) end %%value = @fsub(%%value1,@fmul(%%value,%%value2)) end exit end warn Unexpected error "(2)"! exit :error if @equal(@error(E),26) dialog set,eValue,Overflow else warn Unexpected error @error(E) at line @error(N)! end goto evloop :close list close,1