Script Calculating Fields to Populate Another Field in ArcPad 10

2788
1
08-11-2015 10:11 AM
BrianBower1
New Contributor

Hey guys,

I am currently using ArcPad to collect field data. I have had several requests of things to figure out with ArcPad and most of them I have figured out and have working great. One request is to populate a field using a script that calculates a formula A-B/ Length * 100.

Sub SumFunction   

  Dim objControl, objForm, Cul_Length, D_DSCt_DSI, riff_ele, WC_Slope, US_In_ele

    Set objControl = ThisEvent.Object

    Set objForm = ThisEvent.Object.Parent 

      riff_ele = objControl.Value 

      WC_Slope = objForm.Controls("txtUS_In_ele").Value - riff_ele / (Cul_Length + D_DSCt_DSI) * 100

      objForm.Controls("txtWC_Slope").Value = WC_Slope

End Sub

1. I am not sure if this script is correct even though it validates ( I am not a programmer but I have studied it a little).

2. Where in ArcPad Studio would I place the script? There are several events to choose from but I am not sure what one I should use.

3. Will this fill in while the form is open or would it need to close and open back up.

If anyone has suggestions on how to get this to work it would be much appreciated.

Thanks

Brian

Tags (2)
0 Kudos
1 Reply
RebeccaStrauch__GISP
MVP Emeritus

Hi Brian,

I don't have a complete answer for you, and unfortunately don't have a lot of time to spend on this today, but I'll try to give you some suggestions on how I've done something similar in the past.  I can't tell you how to do it using ArcPad Studio since I typically have just edited my files directly (done before the current versions of ArcPad Studio).

I have a subroutine to create the feature (point for this example) which calls a variety of of suboroutines to, eg, grab attributes from a polygon layer, etc., and then call my PopulateCommonFields ..which is more or less the GPS attributes, and the my PopulateUniqueFields.

In my PopulateUniqueFields subroutine, I use "Case" to check to see what layer it is, then based on this, it will do different calculations and then populate the fields.  

I make use of 

     newVariable = Application.UserProperties("<ItemName")

...do may calculations with my newVariableto calculate myResult

     ObjRS.Fields.Item("<ItemName").value = myResult

I have not calculated and populated a Form with the result if the form is already open, but I have saved/retrieved variables, and then used it to populate a new form.

re: #2 - I keep all my scripts in multiple .vbs files to keep them a bit more organized, and call them all in my .vbs at the end of my .apa file.  The subroutines can go in any of those .vbs files, as long as the environment (variables, etc) is set as needed.

Sorry that this isn't really an answer, but maybe this can jump start some things to look into.

0 Kudos