Generate Pilotdoc Files In Notes

PilotDOC is a file format used on Palm devices to display large text files.

This class allows you to generate & install PilotDOC files directly from Notes.

Tested: Win95, Notes R4.5, PalmOS 3.3


PalmDocName (Read/Write) String


New (PalmDocName as String)
AppendText (Text as String)
AddNewLine (Count as Integer)
Save (Path as String, AutoInstall as [True/False])
Install (Path as String [Optional], AutoRemove as [True/False][Default if path
not specified])


Sub Click(Source As Button)
Dim sess As New NotesSession
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim pd As New PilotDOC("Budget Meeting")

Set uidoc = ws.CurrentDocument
Call pd.AppendText(uidoc.FieldGetText("PilotText"))
Call pd.Save("c:\test.pdb",False)
End If
End Sub
'PilotDOC Class 1.0
'Developed by Daniel Alvers (daniel.alvers@au.pwcglobal.com

Const constRECSIZE = 4096
Const constCREATOR = "TEXt"
Const constTYPE = "REAd"
Const constTIME = "?D??D?"


Public Const HKEY_CURRENT_USER = &H80000001
Public Const KEY_QUERY_VALUE = &H1

'Registry Functions
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (Byval
hKey As Long, Byval lpSubKey As String, Byval ulOptions As Long, Byval
samDesired As Long, phkResult As Long) As Long
Declare Function RegQueryString Lib "advapi32.dll" Alias "RegQueryValueExA"
(Byval hKey As Long, Byval lpValueName As String, Byval lpReserved As Long,
lpType As Long, Byval lpData As String, lpcbData As Long) As Long
Declare Function RegCloseKey Lib "advapi32.dll" Alias "RegCloseKey" (Byval hKey
As Long) As Long

'Temp path functions
Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (Byval
nBufferLength As Long, Byval lpBuffer As String) As Long
Declare Function GetTempFileName Lib "kernel32" Alias "GetTempFileNameA" (Byval
lpszPath As String, Byval lpPrefixString As String, Byval wUnique As Long,
Byval lpTempFileName As String) As Long

Class PilotDOC

Private szPalmCorePath As String
Private szPalmDocPath As String
Private szPalmDocText As String

Public PalmDocName As String

Private Sub WriteStrToPDB(wFileNum As Integer, szText As String)

Dim szChar1 As String * 1
Dim szChar2 As String * 1
Dim szOut As String * 1
Dim wOddChars As Integer
Dim dwTextLen As Long
Dim dwCharPtr As Long

dwTextLen = Len(szText)

If Not dwTextLen Mod 2 = 0 Then
wOddChars = True
szText = szText + " "
End If

dwCharPtr = 1
Do Until dwCharPtr > dwTextLen
szChar1 = Mid(szText,dwCharPtr,1)
szChar2 = Mid(szText,dwCharPtr + 1,1)
szOut = Uchr(Asc(szChar2) * &H100 + Asc(szChar1))
Put #wFileNum,,szOut
dwCharPtr = dwCharPtr + 2

If wOddChars Then Seek #wFileNum,Loc(wFileNum)

End Sub

Private Sub WriteWordToPDB (wFileNum As Integer, wValue As Integer)

Dim szLow As String

szLow = Uchr(((wValue And 65280) / &H0100) + ((wValue And &HFF) *
Put #wFileNum,,szLow

End Sub

Private Sub WriteLongToPDB (wFileNum As Integer, dwValue As Long)

Dim szHigh As String
Dim szLow As String

szHigh = Uchr(((dwValue And &HFF0000) / &H0100) + ((dwValue And
&HFF000000) / &H01000000))
szLow = Uchr(((dwValue And 65280) / &H0100) + ((dwValue And &HFF) *

Put #wFileNum,,szHigh
Put #wFileNum,,szLow

End Sub

Public Sub New(szDocName As String)
PalmDocName = szDocName
End Sub

Public Sub AppendText(szText As String)
szPalmDocText = szPalmDocText + szText
End Sub

Public Sub AddNewLine( wCount As Integer)
szPalmDocText = szPalmDocText + String(wCount,10)
End Sub

Private Sub StripChr13FromText
Do While Not Instr(Me.szPalmDocText,Chr(13)) = 0
Mid(Me.szPalmDocText,Instr(Me.szPalmDocText,Chr(13)),1) = " "
End Sub

Private Function GetCorePalmPath() As String
Dim dwKey As Long
Dim szRetVal As String * 255
Dim szResult As String
Dim lpDataType As Long
Dim lpDataLen As Long

szRetVal = Str

This was first published in November 2000

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.