Get a Jumpstart with our Sample Apps
Results 1 to 15 of 15

Thread: TABLE.FIELDNAME_CHANGE() Doesn't Work

  1. #1
    Member awj's Avatar
    Real Name
    Andrew W. Janert
    Join Date
    Jan 2001
    Location
    Calgary, Alberta, Canada
    Posts
    230

    Default TABLE.FIELDNAME_CHANGE() Doesn't Work

    Hi there;

    I use the above function to change the name of a field in a table, but all it does is ENCRYPT ALL of the fieldnames. Much like the attached JPG file.

    Has anyone else run into this problem, and / or come up with a solution?

    I really need for this to work, any help would be appreciated!

    awj :confused:

  2. #2
    "Certified" Alphaholic Lance Gurd's Avatar
    Real Name
    Lance Gurd
    Join Date
    Jun 2005
    Location
    Southampton, UK
    Posts
    1,373

    Default Re: TABLE.FIELDNAME_CHANGE() Doesn't Work

    Andrew,

    Works for me!

    attached zip file, once unzipped, check out names table. Two fields name1 and name2.

    Run the script on code tab - rename. two fields are now First_name and Last_name.

  3. #3
    Member awj's Avatar
    Real Name
    Andrew W. Janert
    Join Date
    Jan 2001
    Location
    Calgary, Alberta, Canada
    Posts
    230

    Default Re: TABLE.FIELDNAME_CHANGE() Doesn't Work

    Hi Lance;

    I'll look at your script tonight and try it. But at my end it was giving me garbled fieldnames in the entire table. Not sure why.

    I'll let you know how this goes!

    thx, awj :)

    Quote Originally Posted by Lance Gurd View Post
    Andrew,

    Works for me!

    attached zip file, once unzipped, check out names table. Two fields name1 and name2.

    Run the script on code tab - rename. two fields are now First_name and Last_name.

  4. #4
    Member awj's Avatar
    Real Name
    Andrew W. Janert
    Join Date
    Jan 2001
    Location
    Calgary, Alberta, Canada
    Posts
    230

    Default Re: TABLE.FIELDNAME_CHANGE() Doesn't Work

    Well; I couldn't wait to try, I tried it here at the office, and no go. This time it didn't do anything at all. The fieldnames are still "name1" and "name2".

    Now I'm totally confused.

    awj :confused:

    Quote Originally Posted by awj View Post
    Hi Lance;

    I'll look at your script tonight and try it. But at my end it was giving me garbled fieldnames in the entire table. Not sure why.

    I'll let you know how this goes!

    thx, awj :)

  5. #5
    Member awj's Avatar
    Real Name
    Andrew W. Janert
    Join Date
    Jan 2001
    Location
    Calgary, Alberta, Canada
    Posts
    230

    Default Re: TABLE.FIELDNAME_CHANGE() Doesn't Work

    Ok, my goof, yours worked now.

    It was the drive letter I forgot to change in this case.

    But it for sure didn't work on my app at home as I know it was the right drive & path etc.

    I'll try again later.

    awj

  6. #6
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,298

    Default Re: TABLE.FIELDNAME_CHANGE() Doesn't Work

    Andrew, you must change Lance's script so that the path to the table matches the physical path to your table on your machine. The path Lance furnished is the path to his table on his machine. It's very unlikely that your path and his path are identical. -- tom

  7. #7
    Member awj's Avatar
    Real Name
    Andrew W. Janert
    Join Date
    Jan 2001
    Location
    Calgary, Alberta, Canada
    Posts
    230

    Default Re: TABLE.FIELDNAME_CHANGE() Doesn't Work

    Hi Tom;

    I found that on his yes! But with my script at home, I double checked the paths etc, and I got it working once, and most of the time it just totally encrypts the fieldnames to jibberish. Not sure why.

    awj

    Quote Originally Posted by Tom Cone Jr View Post
    Andrew, you must change Lance's script so that the path to the table matches the physical path to your table on your machine. The path Lance furnished is the path to his table on his machine. It's very unlikely that your path and his path are identical. -- tom

  8. #8
    Member awj's Avatar
    Real Name
    Andrew W. Janert
    Join Date
    Jan 2001
    Location
    Calgary, Alberta, Canada
    Posts
    230

    Default Re: TABLE.FIELDNAME_CHANGE() Doesn't Work

    Hi there; Monday morning epiphany!

    I finally discovered the problem. A bit of an oversight, but now it makes sense. When the tables are encrypted, you can't do anything with them, but when I decrypt them, then run the code - no problem!! That's it!!

    awj

  9. #9
    Member
    Real Name
    SIJI FRANCIS
    Join Date
    Feb 2017
    Posts
    14

    Default Re: TABLE.FIELDNAME_CHANGE() Doesn't Work

    Good day All,

    I have a same problem ,TABLE.FIELDNAME_CHANGE() Doesn't Work. I tried to change field name in xbasics but still showing old name

  10. #10
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,698

    Default Re: TABLE.FIELDNAME_CHANGE() Doesn't Work

    TABLE.FIELDNAME_CHANGE() Doesn't Work
    It does work if you use it properly. Show us your code.

    Note that you must supply the full drive-path-tablename-extension as the first parameter.
    There can be only one.

  11. #11
    Member
    Real Name
    SIJI FRANCIS
    Join Date
    Feb 2017
    Posts
    14

    Default Re: TABLE.FIELDNAME_CHANGE() Doesn't Work

    dim t as p
    t = table.open(e.inputFilename)
    t.batch_begin()
    for i = 1 to count

    if variable_exists("t.empl_id")= .F. then

    table.fieldname_change(e.inputFilename, "badge_number", "empl_id")

    end if
    t.change_end(.t.)
    t.fetch_next()

    next i

  12. #12
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,698

    Default Re: TABLE.FIELDNAME_CHANGE() Doesn't Work

    Where should I start?

    e.inputFilename - what is stored in this variable? It must be the full drive-path-tablename_extension, it can't be just the tablename.
    count - where is this initialized ?
    t.batch_begin() - this must be followed by t.batch_end() somewhere in the script.
    t.change_end(.t.) - this must be preceeded by t.change_begin(.t.) somewhere in the script
    table.open(e.inputFilename) - this should be followed by t.close() at the end of the script

    There is no need to have the for I = 1 to count ...next I loop. If the fieldname is changed it only needs to be done once for the table, not for each record.
    There can be only one.

  13. #13
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,698

    Default Re: TABLE.FIELDNAME_CHANGE() Doesn't Work

    Try it this way, ensuring that you have the proper value in the f.inputfilename variable.

    dim t as p
    dim flds as C
    t = table.open(e.inputFilename)
    flds = t.field_name_get()
    t.close()
    if ("empl_id" !$ flds) = .F. then
    table.fieldname_change(e.inputFilename, "badge_number", "empl_id")
    end if
    There can be only one.

  14. #14
    Member
    Real Name
    SIJI FRANCIS
    Join Date
    Feb 2017
    Posts
    14

    Default Re: TABLE.FIELDNAME_CHANGE() Doesn't Work

    i have modified the script like. Still its not working

    dim t as p
    t = table.open(e.inputFilename) '//e.inputFilename - the name of the temporary .dbf(C:\Users\sijif\AppData\Local\Temp\tmpEA74.dbf) table that my function will process

    if variable_exists("t.empl_id")= .F. then
    t.change_begin()
    tname = t.filename_get()
    t.fieldname_change(tname, "BADGE_NUMBER", "EMPL_ID")
    t.change_end(.t.)
    t.batch_end()
    end if
    t.close()

  15. #15
    Member
    Real Name
    SIJI FRANCIS
    Join Date
    Feb 2017
    Posts
    14

    Default Re: TABLE.FIELDNAME_CHANGE() Doesn't Work

    Hi Stan Mathews ,

    Thank you so much for your help, Its working now

Similar Threads

  1. Replies: 1
    Last Post: 09-16-2006, 10:05 AM
  2. Can't get browse edited browse table to work
    By hanson in forum Alpha Five Version 6
    Replies: 8
    Last Post: 08-07-2004, 11:17 AM
  3. table.fieldname_change() Problems
    By john faulling in forum Alpha Five Version 5
    Replies: 4
    Last Post: 02-21-2004, 09:22 AM
  4. Runtime: New Database & Drop Table Still Work
    By Peter.Greulich in forum Alpha Five Version 5
    Replies: 2
    Last Post: 01-20-2003, 12:18 PM

Posting Permissions

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