Skip to content

Understanding “Get”

Forums Forums SIMPOL Programming Understanding “Get”

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #293
    JD Kromkowski
    Participant

    If I know the specific name of field I can easily do this integer iSSN iSSN = appw.form.masterrecord.record.get(appw.form.mastertable.table!SSN) and iSSN will have the value of the SSN field for the current record. But if I’m not exactly sure of the name of the fields, I still should be able to generically get the names of the fields and the actual current values. I’ve tried this any number of ways, primarily ending up with 901 error. what do I need to do? anyvalue aTest,sTest sbme1field fldTest integer c array a a =@ array.new() a =@ appw.form.mastertable.fieldinfo c = a[] c = c-1 // trying hear to run through while c > 0 aTest = a[c] a[c,1] =@ a[aTest] // fldTest =@ appw.form.mastertable.table.firstfield // fldTest = fldTest.next ? // have also tried getting the field from my array but just can // figure this out sTest = appw.form.masterrecord.record.get(appw.form.mastertable.table!fldTest) // why should this give me 901 error but if I do this // sTest = appw.form.masterrecord.record.get(appw.form.mastertable.table!INITS) // There is no problem // c= c-1 end while

    #1511
    JD Kromkowski
    Participant

    I've tried to pair this down to a version of the documentation
    (Object-Oriented Database Access Chapter 13), which works fine (so who
    knows):

    sbme1record r
    sbme1field fld
    string sResult
    integer c
    c = appw.form.mastertable.fieldinfo[]
    r =@ appw.form.masterrecord.record
    fld =@ r.table.firstfield
    while c > 0
    if fld.datatype =@= string
    sResult = fld.name + ": " + r.get(fld) + "{d}{a}"
    else if fld.datatype =@= integer or fld.datatype =@= date or
    fld.datatype =@= time
    sResult = fld.name + ": " + .tostr(r.get(fld), 10) + "{d}{a}"
    else if fld.datatype =@= number
    sResult = fld.name + ": " + .tostr(.fix(r.get(fld), 100), 10) +
    "{d}{a}"
    end if
    fld =@ fld.next
    c = c -1
    end while

    #1450
    Michael
    Keymaster

    On 28/03/2012 20:06, JDK wrote:
    > I've tried to pair this down to a version of the documentation (Object-Oriented Database Access Chapter 13), which works fine
    > (so who knows):
    >
    > sbme1record r
    > sbme1field fld
    > string sResult
    > integer c
    > c = appw.form.mastertable.fieldinfo[]
    > r =@ appw.form.masterrecord.record
    > fld =@ r.table.firstfield
    > while c > 0
    > if fld.datatype =@= string
    > sResult = fld.name + ": " + r.get(fld) + "{d}{a}"
    > else if fld.datatype =@= integer or fld.datatype =@= date or
    > fld.datatype =@= time
    > sResult = fld.name + ": " + .tostr(r.get(fld), 10) + "{d}{a}"
    > else if fld.datatype =@= number
    > sResult = fld.name + ": " + .tostr(.fix(r.get(fld), 100), 10) +
    > "{d}{a}"
    > end if
    > fld =@ fld.next
    > c = c -1
    > end while
    >

    You don't need to know field names to work with them, but I have found in most of my application code that I usually *do* know the
    field names, and it is easier to read and clearer. You don't need to use get() at all. You can do this:

    s = r!Lastname

    or

    r!Lastname = s

    Where s is a string and r is a record of a table that has a Lastname field. This is case-sensitive, so you need to make sure of
    the spelling of the field name.

    Ciao, Neil

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.