max string length

17 Posts
3 Users
0 Likes
57 Views
(@j.becker@pcvue.de)
Posts: 0
New Member Guest
 

Hello,

in the help, there is a description, how to set the max length of a string variable (scada basic intern) to a maximum of 8196:

Changing the maximum length of a character string

The default maximum length of a character string is 2047. This can be changed by adding the following line to the global program.

SYS MAXARGSTRINGS=nnnn

Where nnnn is the maximum number of characters in the range 2047 to 8191.

Problem is, that is seems not to work or where to paste the line?

Second question is also, that using the new GetCollection - method to retrieve all the mimics, we face relatively fast the limit of 8196.

Although, I do not really understand, where the limit is reached in my code:

sub closeMimic(m,b)
DIM CPATH AS STR;
DIM EXPRESSION_CPATH AS STR; 
DIM i AS INTEGER;
DIM hbuffer As Long;
Dim Count As Integer;
dim m_name as str;
dim m_branch as str;
dim m_x as str;
dim m_y as str;
dim sXmlFileName as str;
dim intvalue as integer;
dim iReturnVal as integer;

 	sXmlFileName = "CTX1";
 	intvalue = len(Window("GETCOLLECTION"));
	hbuffer = ALLOC_BUFFER(intvalue);
	SEQ_BUFFER("INSERTFIELD", 1, hbuffer, "", Window("GETCOLLECTION"));
	iReturnVal = XMLPATH("LOAD", sXmlFileName, hbuffer); 
	Count = XMLPATH("COUNT", sXmlFileName,"Mimics/Mimic");
	
				deb_print("m",m);
				deb_print("b",b);
	
	for (i=1; i<=Count;i++)

		EXPRESSION_CPATH="Mimics/Mimic[%i]/Name[1]";
		CPATH=FORMAT(EXPRESSION_CPATH,i);

		m_name = XMLPATH("GETSTR", sXmlFileName, AddString("Mimics/Mimic[", TOC(i), "]/Name[1]"));
		m_branch = XMLPATH("GETSTR", sXmlFileName, AddString("Mimics/Mimic[", TOC(i), "]/Branch[1]"));
		

				deb_print("m_name",m_name);
				deb_print("m_branch",m_branch);
		
		if(CmpString(m,"")==1)then
			 

			 
			 
			 if(CmpString(m_name,"Liegenschaft_Counter_Content_right.mmc")==0 && CmpString(helper_getParentBranch(helper_getParentBranch(b)),helper_getParentBranch(helper_getParentBranch(m_branch)))==1) then
							 deb_print("special case: Liegenschaft - Counter","");
				
				m_x = XMLPATH("GETSTR", sXmlFileName, AddString("Mimics/Mimic[", TOC(i), "]/Left[1]"));
				m_y = XMLPATH("GETSTR", sXmlFileName, AddString("Mimics/Mimic[", TOC(i), "]/Top[1]"));
					
				Window("CLOSE", m, m_branch);
			end if
		else
	 		if(CmpString(m_name,m)==0 && CmpString(helper_getParentBranch(b),helper_getParentBranch(m_branch))==1) then
				m_x = XMLPATH("GETSTR", sXmlFileName, AddString("Mimics/Mimic[", TOC(i), "]/Left[1]"));
				m_y = XMLPATH("GETSTR", sXmlFileName, AddString("Mimics/Mimic[", TOC(i), "]/Top[1]"));
					
				Window("CLOSE", m, m_branch);
			end if
	 	end if
	Next
 
	FREE_BUFFER(hbuffer);  
end sub
 
Posted : 05/12/2017 4:06 pm
f.martin
(@f-martinarcinfo-com)
Posts: 148
Member Admin
 

Hello,

The MAXARGSTRINGS has to be inserted in the first lines of the global program.
I just tested it with v12 and its working fine.

 
Posted : 05/12/2017 4:34 pm
(@j.becker@pcvue.de)
Posts: 0
New Member Guest
 

hi, thanks, but it does not working for me.
I wrote the line:
SYS MAXARGSTRINGS=8196
in the very first line of my global program and I get the msg inthe evt-viewer:
[SCADA Basic] MAXARGSTRINGS is set to 8191 (Max:8191),
so seems to be accepted, but i am getting still the msg in the evt-viewer:
2017/12/05,11:47:04.736,6,W,,1,pcvue_test,1,CopyField, the size of the string to copy is too large, size=2689 max=2047 string= 10Header
10025018950100Liegenschaft_Counter.mmc
Magdlos.DGH2025050018950100Liegenschaft_Counter.mmc
Kom.LG13075150018950100Liegenschaft_Counter.mmc
Kom.LG240125250018950100<Mimi

If you see the code, the interesting point is, that I never use the big string in a str-var, hmmm.

also confusing, what Armin told me right now, is, that following is written in the example-field of the help :

Examples

Sub func1 ()

‘--------local variable

Dim cMystring as STR;

cMmystring = Addstring(“”, “…..”); ‘up to 32000 chars

 
Posted : 05/12/2017 4:57 pm
n.kunzer
(@n-kunzerarcinfo-com)
Posts: 1236
Member Moderator
 

For the copyfield message you must make a SPR. This message appears when PcVue tries to set a string bigger than expected but that's INTERNALLY. Meaning it looks like your MAXARGSTRINGS is well taken in account but there is another error. I bet the issue is coming from the instruction LEN

Don't forget giving your project + procedure to reproduce with the SPR

And then, another SPR for the help as 32,000 chars is the limit for the PcVUe Text variables and not the Scada Basic strings.

Nico

 
Posted : 05/12/2017 5:19 pm
n.kunzer
(@n-kunzerarcinfo-com)
Posts: 1236
Member Moderator
 

ooopps click Submit too fast.

So, try allocating your buffer with a fixed large value instead just the Len(Window("GETCOLLECTION")).

I bet no more CopyField 😉

Nico

 
Posted : 05/12/2017 5:21 pm
n.kunzer
(@n-kunzerarcinfo-com)
Posts: 1236
Member Moderator
 

And why are you doing this?
SEQ_BUFFER("INSERTFIELD", 1, hbuffer, "", Window("GETCOLLECTION"));

 
Posted : 05/12/2017 5:22 pm
(@j.becker@pcvue.de)
Posts: 0
New Member Guest
 

There is no help for that, so I could only use the examples from Anna.
I think it is because of the formatting?
I will ask Anna / Nico D.

By the way, how do you format the SCADA BAsic in the forum into the Editor-style?

And no, using intvalue = 10000; did not help. same msg.

 
Posted : 05/12/2017 5:25 pm
n.kunzer
(@n-kunzerarcinfo-com)
Posts: 1236
Member Moderator
 

Arrrgh I lost my bet 🙁

To format your text you must use the icons up to the smileys.
Select your text, click the icon representing a document having xml tags (16th icon from the left)

Nico

 
Posted : 05/12/2017 5:42 pm
f.martin
(@f-martinarcinfo-com)
Posts: 148
Member Admin
 

WINDOW("GETCOLLECTION") already returns a buffer

Dim hBuf as long;

hBuf = WINDOW("GETCOLLECTION");

'whatever you want

FREE_BUFFER(hBuf);
 
Posted : 05/12/2017 6:09 pm
(@j.becker@pcvue.de)
Posts: 0
New Member Guest
 

really?
print(Window("GetCollection")) will print the xml inside, so for me it is string , no?

but,

print(Alloc_buffer(1000)) will print a long?

maybe I missanderstand something?

 
Posted : 05/12/2017 6:26 pm
f.martin
(@f-martinarcinfo-com)
Posts: 148
Member Admin
 

My bad. I misunderstood what Nicolas D. told me.
The function returns the xml String.

Dim sXmlContent as str;
Dim hXmlBuf as long;

sXmlContent = WINDOW("GETCOLLECTION");
XMLPATH("LOAD", "CTX1", sXmlContent);


'Whatever you want

XMLPATH("UNLOAD","CTX1");

XMLPATH should work with an input string, but if not, SEQ_BUFFER("PUT_LINE",...) is probably easier to use and understand than INSERTFIELD.

 
Posted : 05/12/2017 7:15 pm
(@j.becker@pcvue.de)
Posts: 0
New Member Guest
 

hi,

I tested line by line and the

SEQ_BUFFER("INSERFIELD",1,buffer," ", Window("GetCollection"))

causes the error-msg.

Why Put-line should be the better way?

in your example, the problem will be the limit of 8196 chars for string vars, when you have about 15 mimics opened, but right now, it could be a solution.

 
Posted : 05/12/2017 7:25 pm
(@j.becker@pcvue.de)
Posts: 0
New Member Guest
 

:sick:
using a string variable, same error-msg appears, but with limit of 255 :blink:
so no workaround?

@Florent: You said you tested and everything works? I used latest nightly build.

I think I will create some SPRs
1. sys param is not taken into account on str-vars and on "Buffer-Transfers"
2. Doc SPR for the 32000 chars
3. wish spr to increase size of str-vars

 
Posted : 06/12/2017 2:16 am
n.kunzer
(@n-kunzerarcinfo-com)
Posts: 1236
Member Moderator
 

Hi Johannes,

I got your original code and checked.
It is working well if you start like that:

 	sXmlFileName = "CTX1";
 	intvalue = 10000;
	hbuffer = ALLOC_BUFFER(intvalue);
	put_buffer(hbuffer, 0, Window("GETCOLLECTION")) ;
	XMLPATH("LOAD", sXmlFileName, hbuffer); 
	
	Count = XMLPATH("COUNT", sXmlFileName,"Mimics/Mimic");
	
	for (i=1; i<=Count;i++)

	'---- here your treatment

	next

The copyfield messages are still here (therefore you still must do your spr) but it works.

Nico

 
Posted : 06/12/2017 10:30 am
f.martin
(@f-martinarcinfo-com)
Posts: 148
Member Admin
 

No SPR on the MAXARGSTRINGS except if you have an error message similar to tis one:

2017/12/06,09:14:19.685,6,W,,9030,,1,BASIC,The Size of parameters is too large, MaxSize=8001 params=
2017/12/06,09:14:19.685,6,A,,9030,,1,BASIC,Program (p) Branch () Line 27
2017/12/06,09:14:19.685,6,A,,9030,,1,BASIC, Check SYS MAXARGSTRINGS in global program (Default: 2047). String overflow caused by parameter 2

I've only seen copyfield errors that are linked to buffer manipulation.

It may also come from the GETCOLLECTION instruction which returns a string. I have to check something with Nicolas D.

To check the MAXARGSTRINGS is correctly interpreated, try to concatenate strings over the fixed limit

Sub TestMaxArgStrings()
	Dim i as integer;
	Dim s as str;
	
	while (i<=900)
		s = addstring (s,"$........ ");
	Wend

End Sub
 
Posted : 06/12/2017 2:22 pm