Re: tsunami help

new topic     » goto parent     » topic index » view thread      » older message » newer message

----- Original Message ----- 
From: "George Walters" <gwalters at sc.rr.com

> I'm trying to figure out how to use tsunami record manager. Here's my
> problem/question.
> 
> I have a record {1,250,"Company 250", 1,3....etc) which is a customer setup
> record.
> 
> 1 = company number (integer) ( 2 digits max)
> 250 = customer number (integer) (6 digits max)
> 
> the key in EUdata base would be " 1    250"

actually {32,company number ,32,32,32,32,32,customer number}
the 32's are white spaces

> rc = trmSegDef (1,"company", 1, 1, 2, 0)
> rc = trmSegDef (2,"CustNbr", 1, 2, 6, 0)

rc = trm_SegDef (1,"company", 1, 1, 2, 0)
rc = trm_SegDef (2,"CustNbr", 2, 3, 6, 0)

meaning,  you can only have 99 company numbers 
and you can have 999999 customer numbers

You can have multiple segments of one particular key

result = trmSegDef(1, "company", 1, 1, 3, 6)
result = trmSegDef(2, "CustNbr",2,38,1,4)
result = trmSegDef(3, "Cust_uniqueID", 2, 4, 30, 4)

note that I assign the third key as a second segment for the second key.
This can be helpfull in many ways but you cant search from the third
key because it belongs to the second key as a seperate segment.

Not very confusing, If you need any help, I'll be writting a tool to create the
database based on how many keys, their name and how many segments per key.
This should be done in a week or so but try what I have written above so you'll
better understand how this works.

The key portions must be fixed width (whitespace left padded, if they are
numbers and if names, right pad) to the length you provided in the trm_SegDef

> Is this how I would try to define the segments? Reading the doc it would
> seem that the segment fields for a key should be strings not integers or
> atoms. So I'm confused on how to get back a record once it's been written.

> record = GegEqual(atom hFile, 1 , {1, 250})............Is this how? Or do I
> have to construct a string key and if so then I'm really confused how the
> input and output get matched up.

After you have created and opened the file,

-- Get the first record
result = trm_GetFirst(hFile, 1)
buffer = trm_GetPosition(hFile, 0)
var = peek4s(buffer) -- var should = 1
val = lPad(sprint(var), 2) -- lPad strips whitspaces from the left (not included
in trm_eu.ew)
result = trm_GegEqual( hFile, key, val)
record = trm_GetRecord(result)

so to answer your question, yes strings are passed...
sprint( ) is used to convert numbers to strings

> thanks for any pointers.
> 
> george

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu