Check for invalid characters in description

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Active user
Rating: 5
Joined: Sep 27, 2011
Company:

I'm trying to check for invalid characters in description fo Goods catalog, here is the Item form module Script:

Code
Var AllowedCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 -/()";

&AtClient
Procedure DescriptionOnChange(Item)
   Length = StrLen(Object.Description);
   For I = 1 To Length Do
      Char = Mid(Object.Description, I);
      If Not Find(AllowedCharacters, Char) Then
         DoMessageBox(NStr("en = 'Invalid characters in description'"));
         Break;
      EndIf;
   EndDo;
EndProcedure


But it produces following errors:

{Catalog.Goods.Form.ItemForm.Form(1,22)}: Expecting ';'
Var AllowedCharacters<<?>> = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567­890 -/()"; (Verification: Server)
{Catalog.Goods.Form.ItemForm.Form(1,23)}: Unknown operator
Var AllowedCharacters <<?>>= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567­890 -/()"; (Verification: Server)
{Catalog.Goods.Form.ItemForm.Form(1,22)}: Expecting ';'
Var AllowedCharacters<<?>> = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567­890 -/()"; (Verification: Thin client)
{Catalog.Goods.Form.ItemForm.Form(1,23)}: Unknown operator
Var AllowedCharacters <<?>>= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567­890 -/()"; (Verification: Thin client)

 
#2
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Mar 15, 2012
Company: no

1c is not support assignment of value in description of variable.

You should to do this in module or in procedure.

Code
Var AllowedCharacters;

&AtClient
Procedure DescriptionOnChange(Item)
    AllowedCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW­XYZ1234567890 -/()";
    Length = StrLen(Object.Description);
    For I = 1 To Length Do
        Char = Mid(Object.Description, I);
        If Not Find(AllowedCharacters, Char) Then
            DoMessageBox(NStr("en = 'Invalid characters in description'"));
            Break;
        EndIf;
    EndDo;
EndProcedure


OR

Code
Var AllowedCharacters;

&AtClient
Procedure DescriptionOnChange(Item)
    Length = StrLen(Object.Description);
    For I = 1 To Length Do
        Char = Mid(Object.Description, I);
        If Not Find(AllowedCharacters, Char) Then
            DoMessageBox(NStr("en = 'Invalid characters in description'"));
            Break;
        EndIf;
    EndDo;
EndProcedure 

AllowedCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW­XYZ1234567890 -/()";

 
#3
People who like this:0Yes/0No
Active user
Rating: 5
Joined: Sep 27, 2011
Company:

Thank you very much! Now it works!

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.