Jose's Read Only Forum 2023

IT-Consultant: Charles Pegge => OxygenBasic => Topic started by: Chris Chancellor on November 15, 2018, 04:34:40 PM

Title: Equivalent of PB MAK function
Post by: Chris Chancellor on November 15, 2018, 04:34:40 PM
Hello Charles

what is the equivalent of  PB  MAK function ? 

see http://www.manmrk.net/tutorials/basic/PowerBASIC/PBWINH/MAK_function.html (http://www.manmrk.net/tutorials/basic/PowerBASIC/PBWINH/MAK_function.html)

from PB Manual it is
Quote
MAK function
Purpose
Create an integral class value of a specified data type.

Syntax
resultvar = MAK(datatype, loworderval, highorderval)

Remarks
Create an integral class value of a specified data type (WORD, DWORD, PTR, INTEGER, LONG, QUAD) from a low-order and a high-order part.

The complements to this function are the HI and LO  functions, which may be used to split a single 32-bit value into two 16-bit components.

Restrictions
MAK supercedes the MAKWRD, MAKDWD, and MAKPTR functions. Those functions are no longer supported, so update your code to use the new syntax.

See also
HI, LO

Example
dwResult = MAK(DWORD, x??, y??)







Title: Re: Equivalent of PB MAK function
Post by: Charles Pegge on November 16, 2018, 04:58:13 AM
Hi Chris,

Something like this:


function makword(byte lower,upper) as word
  return upper*0x100+lower
end function

function makdword(word lower,upper) as dword
  return upper*0x10000+lower
end function

'masking tests
int a,b
a=0x30101
b=0x30202
print hex makword a,b '201
print hex makdword a,b '2020101

Title: Re: Equivalent of PB MAK function
Post by: Chris Chancellor on November 16, 2018, 05:34:00 AM
Thanxx a lot Charles

i will test it out against PB to see if they work out