Forums › Forums › SIMPOL Programming › Understanding “Get”
- This topic has 2 replies, 2 voices, and was last updated 12 years, 1 month ago by JD Kromkowski.
- AuthorPosts
- March 28, 2012 at 4:52 pm #293JD KromkowskiParticipant
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
March 28, 2012 at 7:06 pm #1511JD KromkowskiParticipantI'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 whileMarch 29, 2012 at 7:06 pm #1450MichaelKeymasterOn 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
- AuthorPosts
- You must be logged in to reply to this topic.