Author Topic: NOVARSEG and the quest for _MEM  (Read 4205 times)

0 Members and 1 Guest are viewing this topic.

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: NOVARSEG and the quest for _MEM
« Reply #15 on: February 15, 2021, 02:55:41 am »
That is, because fixed length strings are directly incorporated into your type, hence 11 bytes, but for variable length strings only a pointer to the string descriptor is incorporated into the type, which should be 4 bytes when using the 32bit version of QB64, while it should be 8 bytes when using the 64bit version of QB64.

In different words, fixed length is incorporated as is, variable length strings are just incorporated AS _OFFSET.
« Last Edit: February 15, 2021, 02:58:52 am by RhoSigma »
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: NOVARSEG and the quest for _MEM
« Reply #16 on: February 15, 2021, 03:22:50 am »
As RhoSigma suggested , the first 4 bytes in the TYPE list is the memory address of variable length STRING S

Code: QB64: [Select]
  1. TYPE ABC
  2.     S AS STRING
  3.     Z AS INTEGER
  4.     Y AS INTEGER
  5.  
  6.  
  7. DIM C AS ABC
  8.  
  9. C.S = "abcdefghijk"
  10.  
  11.  
  12.  
  13. m = _MEM(C)
  14.  
  15. _MEMGET m, m.OFFSET, N
  16.  

PRINT N = memory address of variable length string.


Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: NOVARSEG and the quest for _MEM
« Reply #17 on: February 15, 2021, 09:27:50 am »
PRINT N = memory address of variable length string.

This may, or may not, be true.  Variable length strings can move around in memory at any time, depending on when your OS does clean up calls and memory packing/rearranging.  When you got the value of N, that's where your variable length string was at that moment, but it could be somewhere else by the time you get to, and complete, the PRINT statement.  It's this movement of variable length strings which is why they don't work with _MEM as it currently exists.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!