/require textutil.tf /load vars_comms.tf /def -F -mregexp -t'^Proprietor: Shallam\.$' t_comm_shallam = /set_comm_shop Shallam /def -F -mregexp -t'^Proprietor: Cyrene\.$' t_comm_cyrene = /set_comm_shop Cyrene /def -F -mregexp -t'^Proprietor: Ashtan\.$' t_comm_ashtan = /set_comm_shop Ashtan /def -F -mregexp -t'^Proprietor: Hashan\.$' t_comm_hashan = /set_comm_shop Hashan /def -F -mregexp -t'^Proprietor: Moghedu\.$' t_comm_moghedu = /set_comm_shop Moghedu /def -F -mregexp -t'^Proprietor: El\'Jazira\.$' t_comm_eljazira = /set_comm_shop ElJazira /def -F -mregexp -t'^Proprietor: Cavemen\.$' t_comm_caveman = /set_comm_shop Cavemen /def -F -mregexp -t'^Proprietor: Thalagor\.$' t_comm_thalagor = /set_comm_shop Thalagor /def -F -mregexp -t'^Proprietor: Aalen Tsol\'aa\.$' t_comm_tsolaa = /set_comm_shop Tsolaa /def -F -mregexp -t'^Proprietor: Tasur\'ke\.$' t_comm_tasurke = /set_comm_shop Tasurke /def -F -mregexp -t'^Proprietor: Shastaan\.$' t_comm_shastaan = /set_comm_shop Shastaan /def -F -mregexp -t'^Proprietor: Jaru\.$' t_comm_jaru = /set_comm_shop Jaru /def -F -mregexp -t'^Proprietor: Grook\.$' t_comm_grook = /set_comm_shop Grook /def -F -mregexp -t'^Proprietor: Blackrock\.$' t_comm_blackrock = /set_comm_shop Blackrock /def -F -mregexp -t'^Proprietor: Mhaldor\.$' t_comm_mhaldor = /set_comm_shop Mhaldor /def -F -mregexp -t'^Proprietor: Eleusis\.$' t_comm_eleusis = /set_comm_shop Eleusis /def set_comm_shop = \ /eval /set shop=%{1} %; \ /def -1 -Fp999 -hPROMPT t_write_comms = /write_comms %; \ /def -mregexp -t'^([A-Za-z]+)\s+(\d+) gp\s+(\d+)\s+(\d+) gp' get_comm_price = \ /eval /set v_comm_name_%{P1}=1 %; \ /eval /set v_comm_%{P1}_%{shop}=%{P2} %{P3} %{P4} %; \ /def -mregexp -t'^([A-Za-z]+)\s+-\s+(\d+)\s+(\d+) gp' get_comm_price2 = \ /eval /set v_comm_name_%{P1}=1 %; \ /eval /set v_comm_%{P1}_%{shop}=0 %{P2} %{P3} %; \ /def write_comms = /listvar v_comm_* %| /writefile vars_comms.tf /def comms = \ /eval /echo -aCyellow $[pad("Comm", -11, "From", -11, "To", -11, "Buy", 8, "Sell", 8, "Profit", 8, "Stock", 8, "Total", 8)] %; \ /quote -S /show_comm `"/listvar -s -mregexp v_comm_name_[^_]+" %; \ /def show_comm = \ /let comm_name=$[replace("v_comm_name_","",{1})] %; \ /eval /quote -S /show_comm2 %{comm_name} v_comm_%{comm_name}_ `"/listvar -s -mregexp v_comm_%{comm_name}_[^_]+" %; \ /def show_comm2 = \ /eval /quote -S /show_comm3 %{1} %{2} %{3} `"/listvar -s -mregexp v_comm_%{comm_name}_[^_]+" %; \ /def show_comm3 = \ /let comm1_prices= %; \ /let comm1_buy= %; \ /let comm1_stock= %; \ /let comm1_sell= %; \ /let comm1_city=$[replace({2},"",{3})] %; \ /let comm2_prices= %; \ /let comm2_buy= %; \ /let comm2_stock= %; \ /let comm2_sell= %; \ /let comm2_city=$[replace({2},"",{4})] %; \ /eval /test comm1_prices := %{3} %; \ /eval /test comm1_buy := $(/car %comm1_prices) %; \ /eval /test comm1_stock := $(/cadr %comm1_prices) %; \ /eval /test comm1_sell := $(/caddr %comm1_prices) %; \ /eval /test comm2_prices := %{4} %; \ /eval /test comm2_buy := $(/car %comm2_prices) %; \ /eval /test comm2_stock := $(/cadr %comm2_prices) %; \ /eval /test comm2_sell := $(/caddr %comm2_prices) %; \ /if (comm1_sell < comm2_buy) \ /eval /echo $[pad({1}, -11, comm1_city, -11, comm2_city, -11, comm1_sell, 8, comm2_buy, 8, comm2_buy-comm1_sell, 8, comm1_stock-10, 8, (comm2_buy-comm1_sell)*(comm1_stock-10), 8)] %; \ /endif %; \