Jump to content
Developer Wiki and Function Reference Links ×

GetSavedSetting and Dynarray of Char


Recommended Posts

Sam, 

   A simple test script would give you your answer. I happen to have one here:

PROCEDURE xxx;
CONST
	category = 'DummyCatAGory';
	setting = 'SomeSetting';
VAR
	valueIN, valueOUT :Dynarray of Char;
	S :String;
	
BEGIN
	valueIN := '/F1 /Helvetica ff [-144 72 div 0 0 144 72 div 0 0] mf def 
/F2 /Helvetica ff [-20 72 div 0 0 20 72 div 0 0] mf def 
/F3 /Helvetica ff 144 72 div scf def 
/F4 /Helvetica ff 20 72 div scf def 
/F5 /Helvetica ff 28 72 div scf def 
/F6 /Helvetica ff [-28 72 div 0 0 28 72 div 0 0] mf def 
/F7 /Helvetica ff 16 72 div scf def 
/F8 /Helvetica-Bold ff 24 72 div scf def 
/F9 /Helvetica ff 36 72 div scf def 
/F10 /Helvetica ff 96 72 div scf def';

	SetSavedSetting(category, setting, valueIN);
	if GetSavedSetting(category, setting, S) then
		message(S)
	else message('Nope');
	
	SysBeep;
END;
Run(xxx);

 

Now what you need to explain is why this script works.

 

1) When I declare "valueOUT" as a Dynarray of Char the complier kicks an error with GetSavedSetting(), saying valueOUT is not the correct variable type.

2) When I substitute string "S" for the return variable "valueOUT", which GetSavedSetting() DOES accept, not only does the script compile (as I expect it to), but it runs and returns all 437 characters in string "S", much more than a STRING's allotted 255 characters is supposed to handle. 

 

So, to answer your questions, YES, SetSavedSetting() WILL accept a DynArray; and NO, GetSavedSetting() WILL NOT accept a DynArray. But who cares since the latter call works with a STRING.

 

——— Caveat, this script was only run in VW 2019. Your mileage may vary in earlier VW versions. ———

 

Raymond

 

 

 

Link to comment
  • Vectorworks, Inc Employee

I think with some changes to support Unicode in Vectorscript with 2019 the limitation of strings being 255 characters was eliminated. If you are using older versions you will still be limited to 255 characters for a string.

Link to comment

Thank you,@klinzey.

   I vaguely remember something being mentioned to that effect, but details and dates tend to blur the longer I do this. I started back in 1990 with MC+2.0. There's a lot of blur piling up. Yes, I see the difference now. Very nice to know. Thanks for mentioning it. 

 

@Sam Jones,

    If you count the number of characters in the Dynarray in my example you'll see why I said, "but it runs and returns all 437 characters in string "S",". In another test I tried it with a text block twice that amount to see if there was a 512 limit, but it worked with 874 characters. The Devil's in the Details.

 

   You can store Dynarrays in a record field, but that's local to file. With a little bit of work you could split your DynArray into 255-char-bite-sized-chunks and store each piece in the SavedSettings library. Some reassembly is required. Or, you could write your data to a file if all else fails. 

 

Raymond

 

Link to comment

My bad.  I looked at the wrong number in the BBEdit footer.  It looks like VW2019 is going to be fine, but 2018 will not.  I can write to a file, but I was hoping not to.  Splitting the string up is doable, but that sort of thing always bites me in the ass down the road.

 

Thanks all

S

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...