TRSM2LL.DLL routine

This routine converts Township, Range and Section to its latitude & Longitude.

Inputs are townships, range and section plus the meridian and/or state.

The meridian may either be attached to the trsm variable or entered separately as the meridian variable.

 

This is the calling routine from Visual Basic

‘-------------------------------------------------------------------------------------

Option Explicit

Private Sub Command1_Click()

'

trsm = InputBox("enter legal location")

meridian = InputBox("OPTIONAL/enter meridian")

state = InputBox("OPTIONAL/enter state XX")

Call trsm2ll(trsm, Len(trsm), meridian, Len(meridian), state, Len(state), lat, lng, lerror)

MsgBox "latitude=" & lat & " longitude=" & lng & " error=" & lerror & " trsm=" & trsm & " state=" & state & " meridian=" & meridian

End Sub

‘---------------------------------------------------------------------------------------------------

And this is the Module declaration.

‘--------------------------------------------------------------------------------------------

Option Explicit

Public lerror As Integer

Public lat As Single

Public lng As Single

Public state As String * 2

Public meridian As String * 2

Public trsm As String * 16

Declare Sub trsm2ll Lib _

"TRSM2LL.DLL" _

(ByVal trsm As String, ByVal l1 As Long, _

ByVal meridian As String, ByVal l2 As Long, _

ByVal state As String, ByVal l3 As Long, _

lat As Single, _

lng As Single, _

lerror As Integer)

 

 

Passing strings from VB to Fortran is certainly confusing. Fortran passes strings in two arguments. The first is the strings address and the second is the strings length declared as Long. In VB the string is declared as ByVal. Integer and floating numbers are passed by reference. So no extra action is required.

The above examples should be followed exactly.

 

The DLL is written in Digital Visual Fortran version 5.0D.

This is the Fortran routine being called.

‘

SUBROUTINE trsm2ll(trsm,meridian,state,latitude,longitude,error)

IMPLICIT NONE

!DEC$ ATTRIBUTES DLLEXPORT :: trsm2ll

!DEC$ ATTRIBUTES ALIAS: 'trsm2ll' :: trsm2ll

REAL :: latitude,longitude

CHARACTER*(*)state,meridian,trsm

INTEGER error

!-------------

CALL legal2ll(trsm,latitude,longitude,state,meridian,error)

!------------

RETURN

END

The following Visual Fortran DLLs must be present on you computer:

DFORRT.DLL

DFORMD.DLL

MSVCRT.DLL

‘--------------------------------------------------------------------

A note on variables passed to & from the Fortran routine.

If your Visual Basic variables are in a different format they must be changed to the form required by the subroutine. Visual Basic & Visual Fortran are very unforgiving of mistakes.

Call trsm2ll(trsm, Len(trsm), meridian, Len(meridian), state, Len(state), lat, lng, lerror)

Lerror returns 0 if the TRS is formatted OK otherwise

1 if ‘N’ or ‘S’ is missing

2 if ‘E’ or ‘W’ is missing

4 if township and range are reversed.

5 if more than 3 digits in township

6 if more than 3 digits in range

7 if township is less than 1

8 if range is less than 1

9 if section is less than 1 or greater than 36

11 if more than 3 digits in section

 

Below are some links to Visual Fortrans documentation on calling Visual Fortran DLLs.

Compaq bought out Digital and the HP bought out Compaq so I guess it is now called HP Visual Fortran.

Calling Visual Fortran from Visual Basic

http://h18009.www1.hp.com/fortran/docs/vf-html/pg/pgwvbusr.htm

You are on your own in C++. I don’t know C++.

VISUAL C/C++ CALLING VISUAL FORTRAN DLL EXAMPLE

http://h18009.www1.hp.com/fortran/examples/vc-example1.html

 

Download
Download the DLLs as a zip file