From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,93847e6bff9fa48a X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: An elementary XFORMS problem Date: 1999/12/29 Message-ID: <386A3730.B35DF3DD@telepath.com>#1/1 X-Deja-AN: 566149829 Content-Transfer-Encoding: 7bit References: <15f5621a.f9b8c972@usw-ex0102-016.remarq.com> X-Accept-Language: en,pdf Content-Type: text/plain; charset=us-ascii X-Complaints-To: Abuse Role , We Care X-Trace: newshog.newsread.com 946484820 216.14.8.33 (Wed, 29 Dec 1999 11:27:00 EST) Organization: Telepath Systems (telepath.com) MIME-Version: 1.0 NNTP-Posting-Date: Wed, 29 Dec 1999 11:27:00 EST Newsgroups: comp.lang.ada Date: 1999-12-29T00:00:00+00:00 List-Id: creator wrote: > I'm trying to make a procedure using XFORMS function FL_SHOW_FSELECTOR. > My procedure looks like this: > > procedure Pehr(O:access FL_OBJECT;ID:Long_Integer) is > Streng:String(1..10); > begin > --Nine blanks > Streng:=" "&FL_NuLL; > Streng:=FL_SHOW_FSELECTOR(" "&FL_NULL," "&FL_NULL,"*"&FL_NULL," > "&FL_NULL); > end Pehr; > > When i run it ,i get an "raised CONSTRAINT_ERROR" I don't know what XFORMS is. But this looks like a pretty basic error. If you are going to assign data into a string (or any array type for that matter) you have to assign *all* the elements at once (and no more), or use a slice of the string. Assuming that FL_Nul is one character, the first assignment is 10 characters, which is OK. But the second one appears to be only 8. I don't know what FL_SHOW_FSELECTOR does to it. But unless it tacks 2 more characters on and returns the result, you are in trouble. Attempting to assign 8 characters into a 10 character string will cause Constraint_Error to be raised. You could do a: Streng(1..8) := FL_SHOW_FSELECTOR(" "&FL_NULL," "&FL_NULL,"*"& FL_NULL," "&FL_NULL); But its better to set the length based on the length of the thing you are copying: Streng(1.. FL_SHOW_FSELECTOR(" "&FL_NULL," "&FL_NULL,"*"& FL_NULL," "&FL_NULL)'length) := FL_SHOW_FSELECTOR(" "&FL_NULL," "& FL_NULL,"*"&FL_NULL," "&FL_NULL); Even better is to only call the function once, so there's no typo issues in the parameters you send to it: Fl_Show_Value : constant String := FL_SHOW_FSELECTOR(" "&FL_NULL," "& FL_NULL,"*"& FL_NULL," "&FL_NULL); begin Streng(1..Fl_Show_Value'length) := Fl_Show_Value; Best yet would be to just initialize the string with the value you want it to have, rather than try to modify it on the fly: Streng : constant String := FL_SHOW_FSELECTOR(" "&FL_NULL," "&FL_NULL,"*"& FL_NULL," "&FL_NULL); begin If what you posted isn't the whole story and you do need to modify it on the fly, you should read through the Ada.Strings packages to see easier/safer ways of modifying strings. -- T.E.D. Home - mailto:dennison@telepath.com WWW - http://www.telepath.com/dennison/Ted/TED.html