Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Script to add calc field

0 views
Skip to first unread message

Richard Gross

unread,
Mar 23, 1999, 3:00:00 AM3/23/99
to
I have a table that includes a field for address and a field for count.

I want to create an Avenue script that will create a new string field
called "Label" that will consist of the field "Address" + "Count"
AsString.

I am really a beginner at this scripting and need some help doing this.

Thanks!

RG

Eurojam

unread,
Mar 24, 1999, 3:00:00 AM3/24/99
to
Im Artikel <info-23039...@192.168.1.141>, in...@centercityphila.org
(Richard Gross) schreibt:

Hi Richard,
there are some ways to do this, at least it is not necessary to create a new
Field "Label", because the Label is always dependent to your Fields "Adress"
and "Count". To avoid redundant data it is better to generate the Label on
request.
However, here is a little script that makes what you want.

'Table must be the active Doc
aVtab= av.GetActiveDoc.GetVtab
aVTab.SetEditable(true)
if (aVTab.IsEditable) then
lF = Field.Make ("Label", #FIELD_CHAR , 20, 0)
aVtab.AddFields({lF})
aF = aVTab.FindField("Adress")
cF = aVTab.FindField("Count")
For each rec in aVTab
a = aVtab.ReturnValue(aF,rec)
c = aVtab.ReturnValue(cF,rec).AsString
aVTab.SetValue(lF,rec,a+c)
end
end
aVTab.SetEditable(FALSE)

Hope this helps.

Stefan Giese
------------------------
in medias res GmbH
Sautierstr. 38
D-79104 Freiburg


UNIX_void

unread,
Mar 24, 1999, 3:00:00 AM3/24/99
to
Subject: Script to add calc field
Date: Tue, 23 Mar 1999 10:09:32 -0500
From: in...@centercityphila.org (Richard Gross)
Organization: Center City District
Newsgroups: comp.soft-sys.gis.esri

------8<------

Hi Richard

If I get you right, something like this might work.

I only tested it briefly, so please get back in case of problems.
Also it could be made in fewer lines, but I find this stile nicer and more
self explaining.

'-------------------------------------------------------------
' Name: Add two fields into new string field
' Date: 990324
' Description: Takes fields of any kind and convert into strings
' and writes the concatenated string in new text field
' Organization: Danish Forest and landscape Research Institute
' Author: Martin Hvidberg, GIS support team.
'-------------------------------------------------------------
' Requirements: An active table
'-------------------------------------------------------------

InTable=av.GetActiveDoc
InVTab=InTable.GetVTab

AddressField = InVTab.FindField("Address")
CountField = InVTab.FindField("Count")

NewFieldList=List.Make
LableField=Field.Make("Lable",#FIELD_CHAR,16,0) 'you might want more space
than 16 chars.
NewFieldList.add(LableField)
InVTab.AddFields(NewFieldList)

for each Record in InVTab
AddressValue=InVTab.ReturnValue(AddressField,Record).AsString
CountValue=InVTab.ReturnValue(CountField,Record).AsString
LableValue=AddressValue+CountValue
InVTab.SetValue(LableField,Record,LableValue)
end 'for each record...

InVTab.Flush

'End of script
'-------------------------------------------------------------

>I am really a beginner at this scripting and need some help doing this.

Don't worry, we are all beginners...

>Thanks!
Your welcome

Best regards

Martin Hvidberg
M.Sc. Physical Geography
Danish Forest and Landscape Institute
Hørsholm Kongevej 11
DK-2970 Hørsholm
DENMARK
Pho.: +45 45 76 32 00 (direct +45 45 17 83 27)
Fax.: +45 45 76 32 33 (direct +45 45 76 57 56)
Email.: m...@fsl.dk
Url: http://www.fsl.dk/eng/


0 new messages