From: spamminator@spamminator.com   
      
   On Fri, 29 Jun 2007 15:50:04 -0700, Ike    
   wrote:   
      
   >On Fri, 29 Jun 2007 12:27:37 -0600, Liz McGuire   
   > wrote:   
   >   
   >>Ike wrote:   
   >>>   
   >>>   
   >>> But, my problem is when I try to read the help tutorial, I can't even   
   >>> find WHERE to put your code, or if it gets attached to an object, etc.   
   >>   
   >>Go to Tools > Settings > Developer Preferences...; make sure the   
   >>ObjectPAL level is set to Advanced and Show developer menus is checked.   
   >>   
   >>Now go into design mode on your form and select the field object (not   
   >>the label, not the editRegion, but the field) and press Ctrl+Spacebar to   
   >>open the Object Explorer.   
   >>   
   >>On the Events tab should be an event named changeValue. Open it up.   
   >>Put my code between the pre-existing method..endMethod lines. Check   
   >>syntax, edit as needed and run.   
   >>   
   >>Liz   
   >   
   >After playing with your code awhile, I discovered that if I cleared a   
   >field I would get an error: "The specified array index is out of   
   >bounds. The index is 1, and the array limit is 0." I seem to have   
   >fixed it by adding another If statement and checking if the field is a   
   >null string before dropping into your routine. It seems I am already   
   >building upon your help.   
   >   
   >   
   >var   
   > stNewValue String   
   > arBreak Array[] String   
   > liCounter longInt   
   > stBadChars String   
   >endVar   
   >   
   >stBadChars = "\n\r\t" ;// line feed, carriage return, tab   
   > ;// add   
   >additional characters as desired   
   >   
   >stNewValue = string(eventInfo.newValue())   
   >stNewValue.breakApart(arBreak,stBadChars)   
   >   
   >if stNewValue <> "" then ;// added a check for a null field   
   > stNewValue = arBreak[1]   
   > if arBreak.size() > 1 then   
   > for liCounter from 2 to arBreak.size()   
   > stNewValue = stNewValue + " " + arBreak[liCounter]   
   > endFor   
   > endIf   
   >endIf   
   >eventInfo.setNewValue(stNewValue)   
      
   [edit]I found that there is no need to execute the line:   
   eventInfo.setNewValue(stNewValue)   
   if clearing the field. This code is more efficient:   
      
   stNewValue = string(eventInfo.newValue())   
   if stNewValue <> "" then ;// added a check for a null field   
    stNewValue.breakApart(arBreak,stBadChars)   
    stNewValue = arBreak[1]   
    if arBreak.size() > 1 then   
    for liCounter from 2 to arBreak.size()   
    stNewValue = stNewValue + " " + arBreak[liCounter]   
    endFor   
    endIf   
    eventInfo.setNewValue(stNewValue)   
   endIf   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|