ZBrushCentral

MemoryBlock and Strings

Hi,

I’m doing some tests on the Memoryblock’s zscriptcommands. I can handle the Numbers, but the scrips give me some problems.
I think that I don’t create the “myStrings” memoryblock; so I need some corrective suggestions. :confused:

The code:
[IConfig,3.1]
//vardef’s:
[vardef,NumberVar,0]
[vardef,StringVar,""]

[MVarDef,“myNumbers”,10,0]
[MemCreate,“myStrings”,1000]

[IButton,“Zplugin:memory”,
“to test basic memoryblock-code”,
[MVarSet,“myNumbers”,1,100]
[varset,NumberVar,[MVarGet,“myNumbers”,1]]
[messageok,[strmerge,“NumberFromMem=”,NumberVar]]

//FROM HERE ZB DOESN’T KNOW HOW TO HANDLE MY CODE:
[MemWriteString,“myStrings”,“Teststring”,1]
[MemReadString,“myStrings”,StringVar]
[messageok,[strmerge,“StringFromMem=”,StringVar]]
]//endbutton

Ed,

In the MemWriteString line you need to make the offset zero, not one.

Or, in the MemReadString add the offset value, one.

What’s happening in your version is a character with value zero is at memblock offset zero, which is acting as a terminator

Sven

Hi Svengali,

thnx for your suggestions;

You did not commend on my [MemCreate,“myStrings”,1000] code; Does that mean that that one is allright also for strings?

Greetings, EddyL

P.S. I have almost finished a new plugin, in which ‘your’ polypainting is very central. I think you will be very interested.

You create a memblock of 1000 bytes, right? You can store any type of variable content that will fit there I suppose. I haven’t worked very much with strings myself. I guess you could create some kind of parser that would scan the memblock for strings stored that way, searching for a terminator byte. Likely Marcus has experimented with the string issue and would have more to say.

OK, now you’ve got me curious about your new plugin… looking forward to seeing what it might be. :smiley:

Sven

Hi Eddy,

Just a friendly reminder. Please remember to assign a unique name for your memoryblock. A memoryblock is accessible from any zscript and so can easily cause problems if it is not unique. EDLzp2_mystrings would make it safer to use now and in the future where somebody might come along and create a mystrings memoryblock.

EDL (EddyLoonstijn) zp2 (your zplugin number 2) and the memoryblock name you wanted to begin with. Of course you can choose whichever system works best for you.

You could also check to see if mystrings existed and then delete it before creating your own mystrings.

[If, [MemGetSize, mystrings], // returns 0 if memblock could not be found
[MemDelete, mystrings]
[MemCreate, mystrings, 1000]
,
[MemCreate, mystrings, 1000]
]

Svengali and TVEyes,

Thx for your helpful advice.
I have already used it in my plugin-scripting.
Greetings, EddyL

A little boy wow gold of eleven, who had wow power levelingbeen thoughtfully assisting in the packing, joined wow power leveling the group of men, and as they rubbed their chins he

spoke up, blushing wow power leveling at the sound of his own voice: "Aunt have got a great fuel-house, and it could be put

there, perhaps, till you’ve found a place wow power leveling to settle in, sir."