Author Topic: Equivalent of PB MAK function  (Read 108 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris Chancellor

  • Sr. Member
  • ****
  • Posts: 269
Equivalent of PB MAK function
« 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

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??)
 

 





Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 665
    • Charles Pegge
Re: Equivalent of PB MAK function
« Reply #1 on: November 16, 2018, 04:58:13 AM »
Hi Chris,

Something like this:

Code: [Select]
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


Offline Chris Chancellor

  • Sr. Member
  • ****
  • Posts: 269
Re: Equivalent of PB MAK function
« Reply #2 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