Alpha Video Training
Results 1 to 6 of 6

Thread: <tbl>Change_Begin and <tbl>.post()

  1. #1
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    786

    Default <tbl>Change_Begin and <tbl>.post()

    How come that the <tbl>.Change() works but the <tbl>.post() throws up the error "Variable post.m_exp1 references a non-existant field"

    The two tables have identical fields and definitions
    The variables are set by the script thus:
    Code:
    .
    .
    LOG = Table.open("Logging")
    RSP = Table.open("RSP_Data")
    .
    .
    .
    SELECT
             CASE log.reg <> rsp.reg
                     ValueOldReg = log.reg
                     ValueNewReg = rsp.reg
                     IF isblank("log.old_id") THEN
                         ValueOld_id = ValueOldReg
                     ELSE
                         ValueOld_id = rtrim(Log.Old_Id)+","+ValueOldReg
                     END IF
             CASE log.reg = rsp.reg
                     ValueNewReg = ""
                     ValueOldReg = ""
                     ValueOld_Id = ""
    END SELECT


    the code for <TBL>.Change

    Code:
    log.change_begin(.t.)
    log.reg       = if(ut(ValueNewReg)   = "",Log.reg,ValueNewReg)
    log.old_id    = if(ut(ValueOld_Id)   = "",Log.old_id,ValueOld_Id)
    log.Icao_code = if(ut(rsp.icao_code) = "",Log.icao_Code,Rsp.Icao_code)
    log.op_unique = if(ut(rsp.op_unique) = "",Log.op_unqiue,rsp.op_unique)
    log.code      = if(ut(rsp.code)      = "",Log.code,rsp.Code)
    log.status    = if(ut(rsp.status)    = "",Log.status,rsp.status)
    log.change_end(.t.)
    The code for <TBL>.POST()

    Code:
    post.t_db     = "D:\My Databases\SBS\data\RSP_Data.DBF"
    post.m_key    = "TYPE_CODE-MSN"
    post.t_key    = "TYPE_CODE-MSN"
    post.m_filter = ""
    post.t_filter = ""
    post.m_count  = 6
    post.m_field1 = "Reg"
    post.m_exp1   = "if(ut(ValueNewReg) = \"\",Log.reg,ValueNewReg)"
    post.m_field2 = "Old_Id"
    post.m_exp2   = "if(ut(ValueOld_Id) = \"\",Log.old_id,ValueOld_Id)"
    post.m_field3 = "icao_code"
    post.m_exp3   = "if(ut(@rsp_Data->icao_code) = \"\",Log.icao_Code,@Rsp_Data->Icao_code)"
    post.m_field4 = "op_unique"
    post.m_exp4   = "if(ut(@rsp_data->op_unique) = \"\",Log.op_unqiue,@rsp_data->op_unique)"
    post.m_field5 = "code"
    post.m_exp5   = "if(ut(@rsp_data->code) = \"\",Log.code,@rsp_data->Code)"
    post.m_field6 = "status"
    post.m_exp6   = "if(ut(@rsp_data->status) = \"\",Log.status,@rsp_data->status)"
    post.t_count = 1
    post.t_case1 = "POSTED"
    post.t_field1 = "@Rsp_Data->Flag"
    post.t_exp1 = "\"Posted\""
    log.post()


    I know I can use the <TBL>.Change(), but I would like to learn how to get the tbl.post() working.

    thanks in anticipation
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

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

    Default Re: <tbl>Change_Begin and <tbl>.post()

    I would try

    post.m_exp1 = "if(ut(ValueNewReg) = \"\",Log.reg,VAR->ValueNewReg)"

    post.m_exp2 = "if(ut(ValueOld_Id) = \"\",Log.old_id,VAR->ValueOld_Id)"


    I think the post operation is expecting field names unless told otherwise.

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

    Default Re: <tbl>Change_Begin and <tbl>.post()

    Graham, I recommend you backup up your data before experimenting with scripts that run table wide operations.

    Your post script doesn't appear to include a filter expression that would limit its range of operation to a single record, as would be the case using your change_begin...change_end script.

  4. #4
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    786

    Default Re: <tbl>Change_Begin and <tbl>.post()

    Thanks Guys,
    managed to suss it out in the end, I seem to have confused myself again!
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

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

    Default Re: <tbl>Change_Begin and <tbl>.post()

    Graham, it could be a help others if you take a minute or two and tell us what you discovered. -- tom

  6. #6
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    786

    Default Re: <tbl>Change_Begin and <tbl>.post()

    Sorry Tom, wont be much use, I should only be using tbl.change as I was updating on a single record basis rather than the block update of tbl.post. I still did not get the post to work anyway, so maybe I'll try again when the need arises.
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

Similar Threads

  1. tbl.mode_get()
    By Ed Barley in forum Alpha Five Version 5
    Replies: 1
    Last Post: 09-05-2005, 01:20 PM
  2. field rule post vs. <tbl>.post()
    By tcampb in forum Alpha Five Version 4
    Replies: 8
    Last Post: 10-22-2003, 11:17 PM
  3. tbl.delete_range()
    By Rick Valenzuela in forum Alpha Five Version 4
    Replies: 3
    Last Post: 10-10-2002, 01:50 PM
  4. Help using <tbl>.post()
    By Graham Wickens in forum Alpha Five Version 4
    Replies: 3
    Last Post: 10-09-2002, 06:21 PM
  5. Cpy Flds in currnt tbl & post to other tbl
    By Danny Marx in forum Alpha Five Version 4
    Replies: 8
    Last Post: 08-24-2000, 10:08 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
  •