To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cad.mlcadOpen lugnet.cad.mlcad in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / MLCad / 116
115  |  117
Subject: 
Reading Part-Lists (was: Suggestion for MLCad Plug-Ins)
Newsgroups: 
lugnet.cad.mlcad, lugnet.cad.dev
Date: 
Fri, 4 Feb 2000 16:13:18 GMT
Viewed: 
3639 times
  
In lugnet.cad.dev, Anders Isaksson wrote:

Steve Bliss skrev i meddelandet ...
[what about color?]

Two approaches:
(where's the second approach?)

1. Allow multiple formats for the string being passed in the WM_COPYDATA
message.  One format is the one you're already using, the part filename and
description. Another message could be defined that included color • information.
A useful format for this second buffer would be a valid LDraw command.
Something like:

1 <color> 0 0 0 1 0 0 0 1 0 0 0 1 <partfile>

Of course! Why didn't *I* think of that? (message type 2)

And (wandering off into left field) this message data format could be defined • as
a snippet of LDraw code, instead of a single command.  This would support
inter-program passing of almost any LDraw-related information.  Multiple • parts,
scaled primitives, submodels, whatever.

One long string with line separators? Or a multi-message approach (coded
'start-of-message', 'part-of-message', 'end-of-message' - message types 3,4
and 5)?

I agree that it is best to move description to the end of the line.  The only
problem is that not all parts have numbers.
No big problem, as we cannot render them anyway if that's the case :-)

The key thing is to have the headers on the first line, so the columns can be • in
any order, left-to-right.  It's not *too* challenging to write the • file-reader
to handle this type of input.

Agreed.

Will you write the specs? :-))

Hmm.

Keep a list of field names in a text file.  This list maps the field names in
various inventory lists to the actual field names.

Ex:

Part,Part
PartID,Part
PartNo,Part
Name,Name
Desc,Name
Color,Color
Colour,Color
Quantity,Quantity
Qty,Quantity

As different people inventory sets, and come up with their own unique field
identifiers, these new data can be added to the list-file.

Internally, the import program can either use the mapped names (Part, Name,
Color, Quantity) or translate these to some other values/objects.

The import program would get the field names from first line of the file.  These
would be translated into an array of targets.  Then the import would process the
rest of the file, sending each field on each line to the matching target.

Here's a routine, written in VB, to load an inventory file into an array.  It
depends on the following (unprovided) routines:

DecodeFieldOrder  - parses and translates a string (containing field names) into
an array of indexes for the import-data array.

Parse - returns and removes a leading substring from a string, up to (not
including) the first occurence of the specified delimiter.

Sub ImportInventory(ByVal sFile as string, ByRef aInventory() as string)
' aInventory is returned sized as [0..3,0..n].  The first dimension indexes
' the input fields:
'    0 - PartID
'    1 - Quantity
'    2 - Color
'    3 - Description

   Dim hFile as long
   Dim sLine as string
   Dim aTarget(3) as long
   Dim i as long
   Dim iLine as long

   hFile = FreeFile
   Open sFile For Input As #hFile
   Line Input #hFile, sLine
   DecodeFieldOrder(sLine, aTarget)

   Redim aInventory(3,0) as string
   iLine = 0

   Do Until EOF(hFile)
      Redim Preserve aInventory(3, iLine) as string

      Line Input #hFile, sLine
      For i = 0 to 3
         aInventory(aTarget(i), iLine) = Parse(sLine, vbTab)
      Next i

      iLine = iLine + 1
   Loop
End Sub

Given the inventory data:

Qty Colour Part Desc
3 Red 3001 Brick 2x4
5 Black 3005 Brick 1x1

DecodeFieldOrder would fill in aTarget like:
aTarget(0) = 1
aTarget(1) = 2
aTarget(2) = 0
aTarget(3) = 3

and ImportInventory would return the aInventory array:

aInventory(0..3,0) = 3001  3  Red    Brick 2x4
aInventory(0..3,1) = 3005  5  Black  Brick 1x1

Steve



Message has 1 Reply:
  Re: Reading Part-Lists (was: Suggestion for MLCad Plug-Ins)
 
Steve Bliss skrev i meddelandet ... (...) Well, I supposed I asked for it :-)) -- Anders Isaksson, Sweden BlockCAD: (2 URLs) (25 years ago, 4-Feb-00, to lugnet.cad.mlcad, lugnet.cad.dev)

Message is in Reply To:
  Re: Suggestion for MLCad Plug-Ins
 
Steve Bliss skrev i meddelandet ... (...) (where's the second approach?) (...) information. (...) Of course! Why didn't *I* think of that? (message type 2) (...) as (...) parts, (...) One long string with line separators? Or a multi-message approach (...) (25 years ago, 2-Feb-00, to lugnet.cad.mlcad, lugnet.cad.dev)

18 Messages in This Thread:




Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR