Jump to content
Developer Wiki and Function Reference Links ×

Is this a bug in SetPrefString?


Recommended Posts

I experienced the following problem with SetPrefString, that looks like a bug:

When I try to change a setting with this procedure, an arbitrary string is passed instead of the one specified in the second parameter. The value stays the same for all calls of the procedure within one run of the script but cannot be reproduced a second time. The value is apparently independant of the actual parameter value (neither its length nor its contents do influence the result), so it looks af if instead of its address some random memory address is passed by the procedure.

The following code can illustrate the problem:

PROCEDURE PrefStringTest;

VAR

frac1, dec1: LONGINT;

format1: INTEGER;

upi1:REAL;

text1, text2, dummy1, dummy2: STRING;

BEGIN

{ set the primary unit marks using SetUnits. It will work correctly }

GetUnits(frac1,dec1,format1,upi1,dummy1,dummy2);

SetUnits(frac1,dec1,format1,upi1,'MMnew',' sq MMnew');

text1:=GetPrefString(154);

text2:=GetPrefString(158);

AlrtDialog(concat('new unit marks (this way it works):',chr(13),

' unit=''',text1,'''',chr(13),' sq. unit=''',text2,''''));

{ set the same fields with SetPrefString. It won't work. }

SetPrefString(154,'MMnew2');

SetPrefString(158,' sq MMnew2');

text1:=GetPrefString(154);

text2:=GetPrefString(158);

AlrtDialog(concat('new unit marks (this way it doesn''t):',chr(13),

' unit=''',text1,''' (should be: ''MMnew2'')',chr(13),

' sq. unit=''',text2,''' (should be: '' sq MMnew2'')'));

{ reset the units for a next test }

Units(4);

{ same problem with the text font name: it has nothing to do with the

unit settings! }

text1:=GetPrefString(100);

AlrtDialog(concat('current text font name = ''',text1,''''));

SetPrefString(100,'Times');

text2:=GetPrefString(100);

AlrtDialog(concat('new text font name = ''',text2,''' (should be: ''Times'')'));

{ there is no way to reset the font name correctly... }

AlrtDialog('Dont forget to restore the font settings manually');

END;

Run(PrefStringTest);

(I tested the problem with almost all selector values given in the VS 11 appendix for string preferences, in all cases with the same result).

Did anyone experience the same problem and is there a solution? Or did I something wrong?

If not, is there a way to work around it? In the above example there is, but for most of the other cases (secondary units settings, units style name of both primary and secondary units) I didn't find any alternative.

Thanks!

Koos van de Linde

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...