Select to view content in your preferred language

Reference file paths in script on Mobile Devices

3800
5
Jump to solution
01-11-2012 07:15 AM
JasonTipton
Frequent Contributor
I have an Applet that automatically updates certain fields every time my user collects data. It was based on the XYZ+ script. My data is projected in UTM, but my users want to be able to record DMS as well. I found a script on the 15th page of http://arcscripts.esri.com/Data/AS15207.pdf that converts to DD.dddd. This is fine and it works great until I try and move it to my Nomad, because there is no C: drive. How do I reference a file at say "\\My Documents\gis\Coordinate System\NAD 1983 UTM Zone 15N.prj" ? "\" being the root directory.

Here's my code:
Sub FA  Set objRS = Map.Selectionlayer.Records objRS.Bookmark = ThisEvent.Bookmark  'define coordinate systems Set pLLCS = Application.CreateAppObject( "CoordSys" ) Set pMCS = Application.CreateAppObject( "CoordSys" )  'Set up Coordinate Systems  \\\\\-----This is where the problem is-----/////////// pMCS.Import("\\My Documents\gis\Coordinate System\NAD 1983 UTM Zone 15N.prj") pLLCS.Import("\\My Documents\gis\Coordinate System\North American Datum 1983.prj")   'Create Map Points and assign coordinate systems Set pMapPt = Application.CreateAppObject("Point") Set pLLPt = Application.CreateAppObject("Point") Set pMapPt.CoordinateSystem = pMCS Set pLLPt.CoordinateSystem = pLLCS 'Set x/y values for original point pMapPt.X = objRS.Fields.Shape.X pMapPt.Y = objRS.Fields.Shape.Y 'transpose the coordinate to lat long Set pLLPt = pLLCS.Project(pMapPt)  For Each f in objRS.Fields  Select Case Ucase(f.name)      CASE "LATSTRING"    f.Value = DMS(pLLpt.Y, "y")   CASE "LONSTRING"    f.Value = DMS(pLLpt.X, "x")   End Select  Next objRS.Update  Set pMapPt = Nothing Set pLLPt = Nothing Set pMCS = Nothing Set pLLCS = Nothing Set objLyr = Nothing Set objRS = Nothing End Sub   Function DMS(v, xy)  absV = abs(v)  degInt = Floor(absV)  min = multDenom(absV, degInt)  if xy = "x" then   degInt = degInt * -1  end if  minInt = Floor(min)  sec = round(multDenom(min, minInt),4)  DMS = degInt & " " & minInt & " " & sec   End Function  Function Floor(d)  dTmp = Round(d)  if dTmp > d then   dTmp = dTmp - 1  End if  Floor = dTmp  End Function Function multDenom(d, dInt)  d = d - dInt  multDenom = d*60  End Function
The code works fine. I just want to include it in case anyone else is trying to do the same thing, or has suggestions on more efficient way.  On the desktop I just change 2 lines to:
'Set up Coordinate Systems  pMCS.Import("C:\Program Files (x86)\ArcGIS\ArcPad10.0\Coordinate System\Projected Coordinate Systems\UTM\NAD 1983\NAD 1983 UTM Zone 15N.prj")  pLLCS.Import("C:\Program Files (x86)\ArcGIS\ArcPad10.0\Coordinate System\Geographic Coordinate Systems\North America\North American Datum 1983.prj")
So how do I reference paths on mobile devices that do not have a root drive letter?
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
GarethWalters
Deactivated User
Hi Jason,

I tend to write my scripts using Preferences.Properties("AppletsPath") so it doesn't matter if the script is on Mobile or PC.

Hope this helps.

Cheers,

Gareth

View solution in original post

0 Kudos
5 Replies
JasonTipton
Frequent Contributor
Found the answer: http://social.msdn.microsoft.com/forums/en-US/netfxcompact/thread/3e73293d-eda5-43b0-8018-a191446439...

Basically, "\" is the root drive. I was on the right track, but instead of "\\" use "\" so change
"\\My Documents"
to
"\My Documents"
0 Kudos
GarethWalters
Deactivated User
Hi Jason,

I tend to write my scripts using Preferences.Properties("AppletsPath") so it doesn't matter if the script is on Mobile or PC.

Hope this helps.

Cheers,

Gareth
0 Kudos
RolfBroch
Frequent Contributor
Hi Jason,

I tend to write my scripts using Preferences.Properties("AppletsPath") so it doesn't matter if the script is on Mobile or PC.

Hope this helps.

Cheers,

Gareth


Hi Gareth, I would assume that the above is only true when you keep to having only one path defined in your applets tag in the config file and not as below

  <PATHS public="C:\Users\Public\Documents\ArcPad" data="C:\Temp\Data" applets="C:\Temp\Applets1;C:\Temp\Applets2" styles="" extensions="" templates=""/>

Rolf
0 Kudos
GarethWalters
Deactivated User
Hi Gareth, I would assume that the above is only true when you keep to having only one path defined in your applets tag in the config file and not as below

  <PATHS public="C:\Users\Public\Documents\ArcPad" data="C:\Temp\Data" applets="C:\Temp\Applets1;C:\Temp\Applets2" styles="" extensions="" templates=""/>

Rolf



Hi Rolf,

As the property is indexed, I could use Preferences.Properties("AppletsPath",2) to get to a specific folder.

Standard ArcPAd Data Path reads: C:\Users\Gareth\Documents,C:\Users\Public\Documents\ArcPad
Preferences.Properties("DataPath",2) would give me: C:\Users\Public\Documents\ArcPad

Cheers,

Gareth
0 Kudos
RolfBroch
Frequent Contributor
Hi Gareth, thanks for the information.

I actually did not know that the value was indexed (although it clearly says so in the ArcPad Help) and this opens up new possibilities for referencing files.

Rolf
0 Kudos