Page 1 of 1

GetField() Syntax

Posted: Sun Nov 17, 2013 7:16 pm
by JeffG
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.

Posted: Mon Nov 18, 2013 7:47 am
by COBS Tech Support
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.



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:


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



Posted: Mon Nov 18, 2013 4:29 pm
by JeffG
Thanks for the rapid response. I am not new to programing, but definitly new to this scripting. What does := mean? I assume it means =?


Posted: Mon Nov 18, 2013 4:34 pm
by COBS Tech Support
:= means "assign" (value)