Alpha Video Training
Results 1 to 5 of 5

Thread: Variable into Field Name expression

  1. #1
    Member Citadel's Avatar
    Real Name
    Alan Storey
    Join Date
    Nov 2006
    Location
    Reading, Berkshire
    Posts
    124

    Default Variable into Field Name expression

    Hi all

    Simple stuff but I'm still learning (slowly!!)

    How do I get A5 to recognise a variable (Comms_History_Field) as a field name in this (simple) code?

    Code:
    dim Comms_History_Field as c = "MyField"
    tbl=table.open(a5.get_path() + "\comms_history")
    
    tbl.fetch_goto(val(Terminal_ID))
    tbl.change_begin()
    	
    tbl->Comms_History_Field=time("Weekday d/M/y h:m")
    	
    tbl.change_end()
    tbl.close()
    Kind Regards
    Alan

  2. #2
    "Certified" Alphaholic DaveM's Avatar
    Real Name
    Dave Mason
    Join Date
    Jul 2000
    Location
    Hudson, FL
    Posts
    5,994

    Default Re: Variable into Field Name expression

    Code:
    tbl.fieldname = var->Comms_History_Field
    'I don't really see what you are doing for sure, but this should put whatever you have in the variable into whatever field you wish as long as it is the same type.
    Others may be able to give better advise.

    .
    Dave Mason
    dave@aldaweb.com

    Skype is dave.mason46

  3. #3
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Variable into Field Name expression

    dim Comms_History_Field as c = "MyField"
    ...
    ...
    tbl->Comms_History_Field=time("Weekday d/M/y h:m")
    I think what you are asking how to do is

    eval("tbl."+MyField) = time("Weekday d/M/y h:m")
    There can be only one.

  4. #4
    Member Citadel's Avatar
    Real Name
    Alan Storey
    Join Date
    Nov 2006
    Location
    Reading, Berkshire
    Posts
    124

    Default Re: Variable into Field Name expression

    Hi Dave

    Thank you for your prompt reply.

    I'm not trying to change an actual field name. The code has been stripped down. I find the the name of the field to use by looking up the info in another table and storing it in a variable - 'Comms_History_Field.' I then want to use that variable in an expression that changes the value of a field (the name of which is stored in 'Comms_History_Field.'

    You know how we sometimes have to use s_quote() to insert quotes around a variable? Well I feel I should be doing the opposite here - removing the 'implied quotes' from around this character variable.

    Clear as mud, eh?
    Kind Regards
    Alan

  5. #5
    Member Citadel's Avatar
    Real Name
    Alan Storey
    Join Date
    Nov 2006
    Location
    Reading, Berkshire
    Posts
    124

    Default Re: Variable into Field Name expression

    Hi Stan

    Thanks very much.

    So easy when you see it done right. I end up saying, "Yeah, it's obvious now!!"

    Thank you both.
    Kind Regards
    Alan

Similar Threads

  1. branch expression sees field name as variable
    By Bob Arbuthnot in forum Alpha Five Version 8
    Replies: 3
    Last Post: 01-27-2008, 11:05 PM
  2. Field Selection by Expression or Variable
    By Robin Hoare in forum Alpha Five Version 7
    Replies: 10
    Last Post: 01-08-2006, 01:47 PM
  3. A/S set Variable to Constant or Expression
    By John Gamble in forum Alpha Five Version 6
    Replies: 11
    Last Post: 12-14-2005, 05:34 PM
  4. variable in a report order expression
    By Mary Nickerson in forum Alpha Five Version 4
    Replies: 3
    Last Post: 01-17-2003, 03:18 AM
  5. Using Script Variable in Expression
    By Dean Hall in forum Alpha Four Versions 7 and 8
    Replies: 4
    Last Post: 11-01-2002, 03:42 AM

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
  •