Custom "Type" elements

DTsEMT

Member
Licensed User
Longtime User
Hi!

Total newb question, I'm sure, but I have a flat file which I read which contains record information on each line, separated by a delimiter:

foo.fle

a]b]c]d]e]f]g]h]i]j.....

I load this into a custom type:

Type FooRecord (a as string, b as string, c as string, d as string...)

and the user gets to modify values. When it comes time to rewrite the record I would like to repopulate a string with foorecord.a, foorecord.b, etc. Is there any way to access the elements of FooRecord? For instance, I currently have to:

Outputstring = FooRecord.a & "]" & FooRecord.b & "]" & FooRecord.c...

Is there any way to do something like this:

For i = 0 to FooRecord.Elements
Outputstruing = outputstring & FooRecord.(i)
Next

??

I'm almost certain I've run across some way to access individual elements of a custom data type using an index, but if so I can't seem to find it again!

Thanks everyone!
:sign0104:
 

HotShoe

Well-Known Member
Licensed User
Longtime User
Hi!

Total newb question, I'm sure, but I have a flat file which I read which contains record information on each line, separated by a delimiter:

foo.fle

a]b]c]d]e]f]g]h]i]j.....

I load this into a custom type:

Type FooRecord (a as string, b as string, c as string, d as string...)

and the user gets to modify values. When it comes time to rewrite the record I would like to repopulate a string with foorecord.a, foorecord.b, etc. Is there any way to access the elements of FooRecord? For instance, I currently have to:

Outputstring = FooRecord.a & "]" & FooRecord.b & "]" & FooRecord.c...

Is there any way to do something like this:

For i = 0 to FooRecord.Elements
Outputstruing = outputstring & FooRecord.(i)
Next

:sign0104:

Sure, just add :

Dim foo as foorecord

Then use foo to access all of the record elements like foo.a, etc. The randomaccessfile type provides for reading and writing objects and works well for records/structures/custom types like this.

--- Jem
 
Upvote 0

DTsEMT

Member
Licensed User
Longtime User
Sure, just add :

Dim foo as foorecord

Then use foo to access all of the record elements like foo.a, etc. The randomaccessfile type provides for reading and writing objects and works well for records/structures/custom types like this.

--- Jem

Jem, thanks! But (and here I confess to extreme personal density this afternoon) I am kind of doing that.

Dim Foo as FooRecord
[read a line from the delimited file and load, for instance...]

Dim dummystring as string
dim dumpbydelimiter() as string

dummystring = file.readlist(name of the file)

dumpbydelimiter = regex.split("]",dummystring)

foo.a = dumpbydelimiter(0) : foo.b = dumpbydelimiter(1)...

[load screen with variables and allow user to modify foo.a, foo.b, etc.]

When it comes time to write back out to the output file, though, if I just write record Foo, the delimiters will be missing. Subsequent reads won't load correctly. I think in my original post I should have said I was looking for something more like:

OutputString = ""
For i = 0 to Foo.<numberofelements>
OutputString = OutputString & Foo.(i) & "]"
Next

Does that make sense at all or...?

Thanks!
 
Last edited:
Upvote 0

DTsEMT

Member
Licensed User
Longtime User
moster67:

Thanks! That was exactly what I was looking for. And thanks to everyone else as well!
 
Upvote 0
Top