MEMFILL: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE:_MEMFILL}} The _MEMFILL statement converts a value to a specified type, then fills memory with that type including any non-whole remainder. {{PageSyntax}} : _MEMFILL {{Parameter|memoryBlock}}, {{Parameter|memoryBlock.OFFSET}}, {{Parameter|fillBytes}}, {{Parameter|value}} [AS {{Parameter|variableType}}] {{Parameters}} * The {{Parameter|memoryBlock}} _MEM memory block is the block referenced to be filled. * {{Parameter|memoryBlock.OFFSET}} is...")
 
No edit summary
Line 11: Line 11:
* {{Parameter|memoryBlock.OFFSET}} is the starting offset of the above referenced memory block.
* {{Parameter|memoryBlock.OFFSET}} is the starting offset of the above referenced memory block.
* The {{Parameter|fillBytes}} is the number of bytes to fill the memory block.
* The {{Parameter|fillBytes}} is the number of bytes to fill the memory block.
* The {{Parameter|value}} is the value to place in the memory block at the designated OFFSET position.  
* The {{Parameter|value}} is the value to place in the memory block at the designated OFFSET position.
* A literal or variable {{Parameter|value}} can be optionally set [[AS]] a variable [[type]] appropriate for the memory block.
* A literal or variable {{Parameter|value}} can be optionally set [[AS]] a variable [[type]] appropriate for the memory block.


Line 21: Line 21:
{{PageExamples}}
{{PageExamples}}
''Example:'' Filling array values quickly using FOR loops or a simple memory fill.
''Example:'' Filling array values quickly using FOR loops or a simple memory fill.
{{CodeStart}} '' ''
{{CodeStart}}
{{Cl|DIM}} a(100, 100) {{Cl|AS}} {{Cl|LONG}}
{{Cl|DIM}} a(100, 100) {{Cl|AS}} {{Cl|LONG}}
{{Cl|DIM}} b(100, 100) {{Cl|AS}} {{Cl|LONG}}
{{Cl|DIM}} b(100, 100) {{Cl|AS}} {{Cl|LONG}}
Line 36: Line 36:
mema = {{Cl|_MEM (function)|_MEM}}(b())
mema = {{Cl|_MEM (function)|_MEM}}(b())
{{Cl|_MEMFILL}} mema, mema.OFFSET, mema.SIZE, 13 {{Cl|AS}} {{Cl|LONG}}
{{Cl|_MEMFILL}} mema, mema.OFFSET, mema.SIZE, 13 {{Cl|AS}} {{Cl|LONG}}
{{Cl|_MEMFREE}} mema '' ''
{{Cl|_MEMFREE}} mema
{{CodeEnd}}
{{CodeEnd}}



Revision as of 02:03, 23 January 2023

The _MEMFILL statement converts a value to a specified type, then fills memory with that type including any non-whole remainder.


Syntax

_MEMFILL memoryBlock, memoryBlock.OFFSET, fillBytes, value [AS variableType]


Template:Parameters

  • The memoryBlock _MEM memory block is the block referenced to be filled.
  • memoryBlock.OFFSET is the starting offset of the above referenced memory block.
  • The fillBytes is the number of bytes to fill the memory block.
  • The value is the value to place in the memory block at the designated OFFSET position.
  • A literal or variable value can be optionally set AS a variable type appropriate for the memory block.


Description

  • To clear previous data from a _MEMNEW memory block, use _MEMFILL with a value of 0.


Examples

Example: Filling array values quickly using FOR loops or a simple memory fill.

DIM a(100, 100) AS LONG
DIM b(100, 100) AS LONG

'filling array a with value 13
FOR i1 = 0 TO 100
    FOR i2 = 0 TO 100
        a(i1, i2) = 13
    NEXT
NEXT

'filling array b with value 13
DIM mema AS _MEM
mema = _MEM(b())
_MEMFILL mema, mema.OFFSET, mema.SIZE, 13 AS LONG
_MEMFREE mema


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link