Alpha Video Training
Results 1 to 4 of 4

Thread: Adding fields dynamically

  1. #1
    Member
    Real Name
    Hernán B. González
    Join Date
    May 2009
    Posts
    12

    Default Adding fields dynamically

    Need to create a file with more than 600 fields,with field names "F1...Fn" and n to 600. No luck using Table.Field_add and evaluateString() Etc.

  2. #2
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,785

    Default Re: Adding fields dynamically

    You haven't given details on wether the field properties are the same for all fields.

    Here is an example that works and should give you some ideas.
    Code:
    dim fldList as C = ""
    dim flname as C = a5.Get_Path() + "\zzzz.dbf"
    
    'Table.create will overwrite an existing table of the same name so check if one exists.
    if file.exists(flname) then
        If  ui_msg_box("Adding a table","Caution this table already exists. Overwrite?",UI_ATTENTION_SYMBOL+UI_YES_NO) <> UI_YES_SELECTED then
            end
        end if    
    end if
    
    'Create the second and subsequent lines in the field list
    'The first field is created by table.create_begin()
    For i = 2 to 6
        fldList = fldList + "table.field_add(\"F"+i+"\",\"c\",20)"  + crlf()
    Next
    
    msgbox(fldList)  'Just for testing
    
    'create the table
    table.create_begin("F1","c",20)  
    evaluate_template(fldList)
    tbl = table.create_end(flname)
    
    'Add the table to the current application
    file_add_to_db(flname)
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  3. #3
    Member
    Real Name
    Hernán B. González
    Join Date
    May 2009
    Posts
    12

    Default Re: Adding fields dynamically

    All fields will have the same properties.

    Your code worked like a sharm! Plus studying it has increased my knowledge. Thanks a lot Tim.

    Regards,

    Hernán

  4. #4
    "Certified" Alphaholic DaveM's Avatar
    Real Name
    Dave Mason
    Join Date
    Jul 2000
    Location
    Hudson, FL
    Posts
    6,026

    Default Re: Adding fields dynamically

    Hernan,

    Do you live in the Miami area?


    .
    Dave Mason
    dave@aldausa.com
    Skype is dave.mason46

Similar Threads

  1. Dynamically adding a new value to a pulldown list
    By telbourn7 in forum Application Server Version 9 - Web/Browser Applications
    Replies: 1
    Last Post: 08-25-2008, 02:23 PM
  2. ADDING INFORMATION TO FIELDS
    By PARCODE in forum Alpha Four Versions 7 and 8
    Replies: 2
    Last Post: 08-31-2005, 06:01 AM
  3. Adding Fields
    By Michael Frayler in forum Alpha Five Version 5
    Replies: 2
    Last Post: 07-05-2003, 04:07 AM
  4. adding various fields
    By marla kilpatrick in forum Alpha Five Version 5
    Replies: 1
    Last Post: 02-25-2003, 11:31 AM
  5. Adding up fields
    By brian in forum Alpha Five Versions 2 and 3
    Replies: 4
    Last Post: 07-19-2001, 05:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •