[AccessD] OT- Files To Psion Handhelds

Stuart McLachlan stuart at lexacorp.com.pg
Tue Aug 3 05:59:27 CDT 2004


On 3 Aug 2004 at 11:36, paul.hartland at fsmail.net wrote:

> To all, I have been given the excellent task of taking over someone’s
> project (as they have left the company).  I basically have to import a
> .csv file in Access the from that data, create the following 3 files
> for our psion handhelds (NEVER done this before, so need all the
> patience and help one can get).  Apparently I write out to three files
> as Binary access .DAT, .IDX, .ID1.  
>
> The .DAT file contains every record with the following detail.
>  
>             PackedBarCode, strItemCode, strDesc, strSPK
>  
> PackedBarCode = 14 digit barcode compressed to 7 bytes.
> strItemCode       = Uncompressed 8 character code.
> strDesc              = Uncompressed 40 character description.
> strSPK               = Uncompressed 7 character packsize.
>  
> The .IDX file contains every 128th record with the following detail.
>  
>             PackedBarCode, Offset
>  
> PackedBarCode = 14 digit barcode compressed to 7 bytes.
> Offset                = Position of the PackedBarCode in the .DAT file (4 bytes)
>  
> The .ID1 file contains every record with the following detail.
>  
> strItemCode       = 8 character uncompressed ItemCode
> Offset                = position of the ItemCode in the .DAT file (4 bytes)
>  

> Has anyone ever worked with psions, and know a fool proof way of doing
> this, I have a meeting in Doncaster on Thursday with the client and
> would really like this section to be working. 

I haven't worked with psions, but I've done plenty of work with 
importing/exporting  files. The destination shouldn't really matter (unless you 
need to worry about things like line terminator characters.)

>From you description, there are no line terminators, this is a straight data 
stream so it should be fairly straightforward.

This solution makes a couple of assumptions:

1. The PackedBarCode is just a set of seven ASCII characters in the normal 
range 32-127.

2.  The Offsets are stored as Longs using the same method as Windows.

Here's one way. Untested, but it should be close. Let me know if it needs 
tweaking:

Option Compare Database
Option Explicit

Type myExport
   PackedBarCode As String * 7
   strItemCode As String * 8
   strDescr As String * 40
   strSPK As String * 7
End Type

Type myIndex
    PackedBarCode As String * 7
    Offset As Long
End Type
Type myIndex1
    strItemCode As String * 8
    Offset As Long
End Type

Function Getdata() As Long
Dim lngRecord As Long ' Record Counter
Dim varOutput As myExport
Dim varIndex As myIndex
Dim varIndex1 As myIndex1

Open "Import.csv" For Input As #1

'Initialise output files as zero length
Open "Output.dat" For Output As #2
Close #2
Open "Output.idx" For Output As #3
Close #3
Open "output.id1" For Output As #4
Close #4

Open "Output.dat" For Random As #2
Open "Output.idx" For Random As #3
Open "output.id1" For Random As #4

While Not EOF(1)
    lngRecord = lngRecord + 1
    Input #1, varOutput.PackedBarCode, varOutput.strDescr, varOutput.strItemCode, varOutput.strSPK
    varIndex1.strItemCode = varOutput.strItemCode
    varIndex1.Offset = (lngRecord - 1) * 62 + 8
    Put #2, , varOutput
    Put #3, , varIndex1
    If lngRecord Mod 128 = 0 Then
        varIndex.PackedBarCode = varOutput.PackedBarCode
        varIndex.Offset = (lngRecord - 1) * 62 + 1
        Put #4, , varIndex
    End If
Wend
Close #1
Close #2
Close #3
Close #4

End Function





 
-- 
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System Support.






More information about the AccessD mailing list