V4RB and changing lengths of varchar fields programmatically

Cindy alvin at ins.co.nz
Sat Aug 16 17:59:17 CDT 2003


Thanks Eric and Francois for your answers. In the end I found the easiest
way to do this was:

  dim baseObject As vBaseObject
  dim fld As vField
  dim str_fld as vvarChar
  fld = mDatabase.baseObject("Units").field("Key_Activities")
  str_fld = vvarChar(fld)
  if ( str_fld <> nil ) then
    str_fld.MaxLength = 6648
  end
  

This worked fine, but thanks for your help.

Cindy

>> Can someone please give me the exact code for changing the length
>> of a varchar field programmatically from Realbasic. Currently the
>> length of my Key_Activities field in my Units Base Object is set
>> at 3096 but I would like to double that. I have tried various
>> ways but none of them seem to get past the debugger.
> 
> Hi, Cindy --
> 
> Probably the very easiest thing to do would be to change it in the Valentina
> application itself -- then the database is set the way you want it.
> 
> Then change it in Rb:  just change 3096 to 6192.
> 
> OK, now that I've read your question more thoroughly, I see you want a
> programmatic answer.  I can't give you exact code at this moment, but
> basically I think you'd want to:
> 
> 1.  Open the database generically (i.e., without all the base object
>   properties, etc., defined), with something like
> 
>   Dim f as FolderItem
>   Dim vdb as VDatabase  // NOT as your subclass!
>   
>   f = (get folderItem of your db here)
>   if not vdb.Open(f) then // error handle
>   end if
>   
> 2.  Then find your field and make your change
> 
>   Dim vc as VVarChar
>   
>   vc = VVarChar(vdb.baseObject("baseobjectname").field("varcharName")
>   vc.maxlength = 6192
> 
> 3.  Finally, close the database and re-open it your usual way, making
>   sure to have changed your field's maxlength property to 6192 in your
>   existing code.
> 
> 
> *HOWEVER*, 6192 is not an efficient VarChar size; I believe you'd want to use
> 6136 or 6648, though my math may be off.  See the Valentina Kernel doc, page
> 22.
> 
> Good luck,
> 
> Erik
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina
> 



More information about the Valentina mailing list