Some time ago there was a MAPM user library available for PB, but there is no support for recent PB versions anymore.
As I haven't found any PB code utilizing the mapm.dll, I decided to post an example for its proper use (or at least how I AM using it

All PB code (PB 4.40, x86-Windows), the compiled mapm.dll (x86, single threaded) as well as the original sources can be downloaded from HERE (left mouse click; 7z archive, 229 kB).
Include file, save as 'mapm_inc.pbi':
Code: Select all
;=====================================================
; Include file for MAPM Library DLL 4.9.2, 4.9.5a
; ---------------------------------------------------
; javabean (March, 2010)
;=====================================================
;Note that the default MAPM library is *NOT* thread safe. MAPM internal data
;structures could get corrupted if multiple MAPM functions are active at the
;same time. The user should guarantee that only one thread is performing
;MAPM functions. This can usually be achieved by a call to the operating
;system to obtain a 'semaphore', 'mutex', or 'critical code section' so
;the operating system will guarantee that only one MAPM thread will be
;active at a time. (Michael C. Ring, 2009)
#LIB=1 ;Library number
PrototypeC.l mapm_init()
PrototypeC.l mapm_free(apmvalue.l)
PrototypeC.l mapm_free_all_mem()
PrototypeC.l mapm_trim_mem_usage()
PrototypeC.l mapm_lib_version(*lib_version)
PrototypeC.l mapm_lib_short_version(*lib_version)
PrototypeC.l mapm_set_string(apmvalue.l, *in_string)
PrototypeC.l mapm_set_double(apmvalue.l, doubleval.d)
PrototypeC.l mapm_set_long(apmvalue.l, longval.l)
PrototypeC.l mapm_to_string(*out_string, decimal_places.l, apmvalue.l)
PrototypeC.l mapm_to_fixpt_string(*out_string, decimal_places.l, apmvalue.l)
PrototypeC.l mapm_to_fixpt_stringex(*out_string, decimal_places.l, apmvalue.l, radix.c, separator_char.c, separator_count.l)
PrototypeC.l mapm_to_fixpt_stringexp(decimal_places.l, apmvalue.l, radix.c, separator_char.c, separator_count.l)
PrototypeC.l mapm_to_integer_string(*out_string, apmvalue.l)
PrototypeC.l mapm_absolute_value(apmresult.l, apmvalue.l)
PrototypeC.l mapm_negate(apmresult.l, apmvalue.l)
PrototypeC.l mapm_copy(apmresult.l, apmvalue.l)
PrototypeC.l mapm_round(apmresult.l, decimal_places.l, apmvalue.l)
PrototypeC.l mapm_compare(apm_num1.l, apm_num2.l)
PrototypeC.l mapm_sign(apm_num.l)
PrototypeC.l mapm_exponent(apm_num.l)
PrototypeC.l mapm_significant_digits(apm_num.l)
PrototypeC.l mapm_is_integer(apm_num.l)
PrototypeC.l mapm_is_even(apm_int.l)
PrototypeC.l mapm_is_odd(apm_int.l)
PrototypeC.l mapm_gcd(apmresult.l, apm_num1.l, apm_num2.l)
PrototypeC.l mapm_lcm(apmresult.l, apm_num1.l, apm_num2.l)
PrototypeC.l mapm_add(apmresult.l, apm_num1.l, apm_num2.l)
PrototypeC.l mapm_subtract(apmresult.l, apm_num1.l, apm_num2.l)
PrototypeC.l mapm_multiply(apmresult.l, apm_num1.l, apm_num2.l)
PrototypeC.l mapm_divide(apmresult.l, apm_num1.l, apm_num2.l)
PrototypeC.l mapm_integer_divide(apmresult.l, apm_num1.l, apm_num2.l)
PrototypeC.l mapm_integer_div_rem(apm_quotient.l, apm_remainder.l, apm_num1.l, apm_num2.l)
PrototypeC.l mapm_reciprocal(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_factorial(apmresult.l, apm_num.l)
PrototypeC.l mapm_floor(apmresult.l, apm_num.l)
PrototypeC.l mapm_ceil(apmresult.l, apm_num.l)
PrototypeC.l mapm_get_random(apm_random_number.l)
PrototypeC.l mapm_set_random_seed(*startingvalue_string)
PrototypeC.l mapm_sqrt(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_cbrt(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_log(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_log10(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_exp(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_pow(apmresult.l, decimal_places.l, apm_x.l, apm_y.l)
PrototypeC.l mapm_integer_pow(apmresult.l, decimal_places.l, apm_x.l, ipower.l)
PrototypeC.l mapm_integer_pow_nr(apmresult.l, apm_x.l, ipower.l)
PrototypeC.l mapm_sin_cos(apm_sin_val.l, apm_cos_val.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_sin(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_cos(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_tan(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_arcsin(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_arccos(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_arctan(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_arctan2(apmresult.l, decimal_places.l, apm_y.l, apm_x.l)
PrototypeC.l mapm_sinh(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_cosh(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_tanh(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_arcsinh(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_arccosh(apmresult.l, decimal_places.l, apm_num.l)
PrototypeC.l mapm_arctanh(apmresult.l, decimal_places.l, apm_num.l)
Macro PREFIX
"_m_apm_
EndMacro
Macro PROTO(name)
Global mapm_#name#.mapm_#name=GetFunction(#LIB,PREFIX#name")
EndMacro
Declare mapm_init_cnst()
Procedure mapm_open(dllfile.s)
If OpenLibrary(#LIB, dllfile)=0
ProcedureReturn #False
EndIf
PROTO(init)
PROTO(free)
PROTO(free_all_mem)
PROTO(trim_mem_usage)
PROTO(lib_version)
PROTO(lib_short_version)
PROTO(set_string)
PROTO(set_double)
PROTO(set_long)
PROTO(to_string)
PROTO(to_fixpt_string)
PROTO(to_fixpt_stringex)
PROTO(to_fixpt_stringexp)
PROTO(to_integer_string)
PROTO(absolute_value)
PROTO(negate)
PROTO(copy)
PROTO(round)
PROTO(compare)
PROTO(sign)
PROTO(exponent)
PROTO(significant_digits)
PROTO(is_integer)
PROTO(is_even)
PROTO(is_odd)
PROTO(gcd)
PROTO(lcm)
PROTO(add)
PROTO(subtract)
PROTO(multiply)
PROTO(divide)
PROTO(integer_divide)
PROTO(integer_div_rem)
PROTO(reciprocal)
PROTO(factorial)
PROTO(floor)
PROTO(ceil)
PROTO(get_random)
PROTO(set_random_seed)
PROTO(sqrt)
PROTO(cbrt)
PROTO(log)
PROTO(log10)
PROTO(exp)
PROTO(pow)
PROTO(integer_pow)
PROTO(integer_pow_nr)
PROTO(sin_cos)
PROTO(sin)
PROTO(cos)
PROTO(tan)
PROTO(arcsin)
PROTO(arccos)
PROTO(arctan)
PROTO(arctan2)
PROTO(sinh)
PROTO(cosh)
PROTO(tanh)
PROTO(arcsinh)
PROTO(arccosh)
PROTO(arctanh)
mapm_init_cnst()
ProcedureReturn #True
EndProcedure
Procedure mapm_init_cnst()
Global MM_Zero.l = mapm_init()
Global MM_One.l = mapm_init()
Global MM_Two.l = mapm_init()
Global MM_Three.l = mapm_init()
Global MM_Four.l = mapm_init()
Global MM_Five.l = mapm_init()
Global MM_Ten.l = mapm_init()
Global MM_0_5.l = mapm_init()
Global MM_LOG_2_BASE_E.l = mapm_init()
Global MM_LOG_3_BASE_E.l = mapm_init()
Global MM_E.l = mapm_init()
Global MM_PI.l = mapm_init()
Global MM_HALF_PI.l = mapm_init()
Global MM_2_PI.l = mapm_init()
Global MM_lc_PI.l = mapm_init()
Global MM_lc_HALF_PI.l = mapm_init()
Global MM_lc_2_PI.l = mapm_init()
Global MM_lc_log2.l = mapm_init()
Global MM_lc_log10.l = mapm_init()
Global MM_lc_log10R.l = mapm_init()
Global MM_0_85.l = mapm_init()
Global MM_5x_125R.l = mapm_init()
Global MM_5x_64R.l = mapm_init()
Global MM_5x_256R.l = mapm_init()
Global MM_5x_Eight.l = mapm_init()
Global MM_5x_Sixteen.l = mapm_init()
Global MM_5x_Twenty.l = mapm_init()
Global MM_LOG_E_BASE_10.l = mapm_init()
Global MM_LOG_10_BASE_E.l = mapm_init()
MM_cnst_PI.s = "3.1415926535897932384626433832795028841971693993751058209749445923078"
MM_cnst_PI + "1640628620899862803482534211706798214808651328230664709384460955"
MM_cnst_E.s = "2.7182818284590452353602874713526624977572470936999595749669676277240"
MM_cnst_E + "76630353547594571382178525166427427466391932003059921817413596629"
MM_cnst_log_2.s = "0.6931471805599453094172321214581765680755001343602552541206800094933"
MM_cnst_log_2 + "93621969694715605863326996418687542001481020570685733685520235758"
MM_cnst_log_3.s = "1.0986122886681096913952452369225257046474905578227494517346943336374"
MM_cnst_log_3 + "9429321860896687361575481373208878797002906595786574236800422593"
MM_cnst_log_10.s = "2.3025850929940456840179914546843642076011014886287729760333279009675"
MM_cnst_log_10 + "7260967735248023599720508959829834196778404228624863340952546508"
MM_cnst_1_log_10.s = "0.4342944819032518276511289189166050822943970058036665661144537831658"
MM_cnst_1_log_10 + "64649208870774729224949338431748318706106744766303733641679287159"
; ------------The following constants have ~520 digits each, If needed-------------------
; MM_cnst_PI.s = "3.1415926535897932384626433832795028841971693993751058209749445923078"
; MM_cnst_PI + "164062862089986280348253421170679821480865132823066470938446095505822"
; MM_cnst_PI + "317253594081284811174502841027019385211055596446229489549303819644288"
; MM_cnst_PI + "109756659334461284756482337867831652712019091456485669234603486104543"
; MM_cnst_PI + "266482133936072602491412737245870066063155881748815209209628292540917"
; MM_cnst_PI + "153643678925903600113305305488204665213841469519415116094330572703657"
; MM_cnst_PI + "595919530921861173819326117931051185480744623799627495673518857527248"
; MM_cnst_PI + "91227938183011949129833673362440656643"
;
; MM_cnst_E.s = "2.7182818284590452353602874713526624977572470936999595749669676277240"
; MM_cnst_E + "766303535475945713821785251664274274663919320030599218174135966290435"
; MM_cnst_E + "729003342952605956307381323286279434907632338298807531952510190115738"
; MM_cnst_E + "341879307021540891499348841675092447614606680822648001684774118537423"
; MM_cnst_E + "454424371075390777449920695517027618386062613313845830007520449338265"
; MM_cnst_E + "602976067371132007093287091274437470472306969772093101416928368190255"
; MM_cnst_E + "151086574637721112523897844250569536967707854499699679468644549059879"
; MM_cnst_E + "3163688923009879312773617821542499923"
;
; MM_cnst_log_2.s = "0.6931471805599453094172321214581765680755001343602552541206800094933"
; MM_cnst_log_2 + "936219696947156058633269964186875420014810205706857336855202357581305"
; MM_cnst_log_2 + "570326707516350759619307275708283714351903070386238916734711233501153"
; MM_cnst_log_2 + "644979552391204751726815749320651555247341395258829504530070953263666"
; MM_cnst_log_2 + "426541042391578149520437404303855008019441706416715186447128399681717"
; MM_cnst_log_2 + "845469570262716310645461502572074024816377733896385506952606683411372"
; MM_cnst_log_2 + "738737229289564935470257626520988596932019650585547647033067936544325"
; MM_cnst_log_2 + "47632744951250406069438147104689946506"
;
; MM_cnst_log_3.s = "1.0986122886681096913952452369225257046474905578227494517346943336374"
; MM_cnst_log_3 + "942932186089668736157548137320887879700290659578657423680042259305198"
; MM_cnst_log_3 + "210528018707672774106031627691833813671793736988443609599037425703167"
; MM_cnst_log_3 + "959115211455919177506713470549401667755802222031702529468975606901065"
; MM_cnst_log_3 + "215056428681380363173732985777823669916547921318181490200301038236301"
; MM_cnst_log_3 + "222486527481982259910974524908964580534670088459650857484441190188570"
; MM_cnst_log_3 + "876474948670796130858294116021661211840014098255143919487688936798494"
; MM_cnst_log_3 + "3022557315353296853452952514592138765"
;
; MM_cnst_log_10.s = "2.3025850929940456840179914546843642076011014886287729760333279009675"
; MM_cnst_log_10 + "726096773524802359972050895982983419677840422862486334095254650828067"
; MM_cnst_log_10 + "566662873690987816894829072083255546808437998948262331985283935053089"
; MM_cnst_log_10 + "653777326288461633662222876982198867465436674744042432743651550489343"
; MM_cnst_log_10 + "149393914796194044002221051017141748003688084012647080685567743216228"
; MM_cnst_log_10 + "355220114804663715659121373450747856947683463616792101806445070648000"
; MM_cnst_log_10 + "277502684916746550586856935673420670581136429224554405758925724208241"
; MM_cnst_log_10 + "31469568901675894025677631135691929203"
;
; MM_cnst_1_log_10.s = "0.4342944819032518276511289189166050822943970058036665661144537831658"
; MM_cnst_1_log_10 + "646492088707747292249493384317483187061067447663037336416792871589639"
; MM_cnst_1_log_10 + "065692210646628122658521270865686703295933708696588266883311636077384"
; MM_cnst_1_log_10 + "905142844348666768646586085135561482123487653435434357317253835622281"
; MM_cnst_1_log_10 + "395603048646652366095539377356176323431916710991411597894962993512457"
; MM_cnst_1_log_10 + "934926357655469077671082419150479910989674900103277537653570270087328"
; MM_cnst_1_log_10 + "550951731440674697951899513594088040423931518868108402544654089797029"
; MM_cnst_1_log_10 + "86328682876262414401345704354613292060"
; ---------------------------------------------------------------------------------------
mapm_set_string(MM_One, @"1")
mapm_set_string(MM_Two, @"2")
mapm_set_string(MM_Three, @"3")
mapm_set_string(MM_Four, @"4")
mapm_set_string(MM_Five, @"5")
mapm_set_string(MM_Ten, @"10")
mapm_set_string(MM_0_5, @"0.5")
mapm_set_string(MM_0_85, @"0.85")
mapm_set_string(MM_5x_125R, @"8.0E-3")
mapm_set_string(MM_5x_64R, @"1.5625E-2")
mapm_set_string(MM_5x_256R, @"3.90625E-3")
mapm_set_string(MM_5x_Eight, @"8")
mapm_set_string(MM_5x_Sixteen, @"16")
mapm_set_string(MM_5x_Twenty, @"20")
mapm_set_string(MM_LOG_2_BASE_E, @MM_cnst_log_2)
mapm_set_string(MM_LOG_3_BASE_E, @MM_cnst_log_3)
mapm_set_string(MM_LOG_10_BASE_E, @MM_cnst_log_10)
mapm_set_string(MM_LOG_E_BASE_10, @MM_cnst_1_log_10)
mapm_set_string(MM_lc_log2, @MM_cnst_log_2)
mapm_set_string(MM_lc_log10, @MM_cnst_log_10)
mapm_set_string(MM_lc_log10R, @MM_cnst_1_log_10)
mapm_set_string(MM_E, @MM_cnst_E)
mapm_set_string(MM_PI, @MM_cnst_PI)
mapm_multiply(MM_HALF_PI, MM_PI, MM_0_5)
mapm_multiply(MM_2_PI, MM_PI, MM_Two)
mapm_copy(MM_lc_PI, MM_PI)
mapm_copy(MM_lc_HALF_PI, MM_HALF_PI)
mapm_copy(MM_lc_2_PI, MM_2_PI)
EndProcedure
Procedure mapm_free_cnst()
mapm_free(MM_Zero)
mapm_free(MM_One)
mapm_free(MM_Two)
mapm_free(MM_Three)
mapm_free(MM_Four)
mapm_free(MM_Five)
mapm_free(MM_Ten)
mapm_free(MM_0_5)
mapm_free(MM_LOG_2_BASE_E)
mapm_free(MM_LOG_3_BASE_E)
mapm_free(MM_E)
mapm_free(MM_PI)
mapm_free(MM_HALF_PI)
mapm_free(MM_2_PI)
mapm_free(MM_lc_PI)
mapm_free(MM_lc_HALF_PI)
mapm_free(MM_lc_2_PI)
mapm_free(MM_lc_log2)
mapm_free(MM_lc_log10)
mapm_free(MM_lc_log10R)
mapm_free(MM_0_85)
mapm_free(MM_5x_125R)
mapm_free(MM_5x_64R)
mapm_free(MM_5x_256R)
mapm_free(MM_5x_Eight)
mapm_free(MM_5x_Sixteen)
mapm_free(MM_5x_Twenty)
mapm_free(MM_LOG_E_BASE_10)
mapm_free(MM_LOG_10_BASE_E)
EndProcedure
Procedure mapm_close()
mapm_free_cnst()
mapm_free_all_mem()
CloseLibrary(#LIB)
EndProcedure
Code: Select all
XIncludeFile "mapm_inc.pbi"
mapm_open("mapm.dll")
a.l = mapm_init()
b.l = mapm_init()
c.l = mapm_init()
r.l = mapm_init()
lib_version$ = Space(80)
mapm_lib_version(@lib_version$)
Debug lib_version$
mapm_set_long(a, 19354)
facto$=Space(256)
mapm_factorial(r, a)
mapm_to_string(@facto$,100, r)
Debug facto$
exp$=Space(256)
mapm_exp(b, 100, a)
mapm_to_string(@exp$,100, b)
Debug exp$
mult$=Space(256)
mapm_multiply(c, MM_E, MM_PI) ;multiply some 'constants'
mapm_to_string(@mult$,100, c)
Debug mult$
;Cleanup
mapm_free(a)
mapm_free(b)
mapm_free(c)
mapm_free(r)
mapm_close()