GetField() Syntax
  • JeffG
    Posts:91
    Joined:Sat Aug 31, 2013 6:50 pm
    Location:Sydney
    GetField() Syntax

    by JeffG » Sun Nov 17, 2013 7:16 pm

    Hi, I have been right through the forum and help files and just can seem to get this right. I want to return the discount value entered into a user field on the Supplier Table.

    My Script is:

    OpenTable("Supplier") .OR. Echo ("Table failed to open")
    Find(Upper(SCCRead("Name2"))) - where Name2 is the supplier code
    nMargin:= GetField('Purchdisc') - Purchdisc is the name of the field in Supplier. It is this value that I want to read.
    nNewList := nCost * nMargin
    SCRWrite("Margin", nMargin)
    CloseTable ()

    All works fine if nMargin is a hard coded number, but as a GetField() it does not want to play.

    Thanks in Advance.
  • COBS Tech Support
    Posts:683
    Joined:Fri Sep 09, 2005 8:23 am

    by COBS Tech Support » Mon Nov 18, 2013 7:47 am

    Your script might work but the syntax is ambiguous so it may also not work.

    To make the script clearer to the interpreter it's recommended to specify the table you are referencing.

    I.e.,

    OpenTable("Supplier")
    Supplier->(Find(Upper(SCCRead("Name2"))))

    You can use GetField() like so:

    x := GetField("Purchdisc", "Supplier"))

    Or just do this:

    nNewList := nCost * Supplier->Purchdisc

    If you want to access a database field, then the syntax is:

    TableName->XXXX

    If you want a function or expression to look at a particular table, then surround the function or expression with round brackets like so:

    TableName->(<expression>)
  • JeffG
    Posts:91
    Joined:Sat Aug 31, 2013 6:50 pm
    Location:Sydney

    :=

    by JeffG » Mon Nov 18, 2013 4:29 pm

    Thanks for the rapid response. I am not new to programing, but definitly new to this scripting. What does := mean? I assume it means =?

    Thanks
  • COBS Tech Support
    Posts:683
    Joined:Fri Sep 09, 2005 8:23 am

    by COBS Tech Support » Mon Nov 18, 2013 4:34 pm

    := means "assign" (value)

Who is online

Users browsing this forum: No registered users and 1 guest