Connecting Tech Pros Worldwide Forums | Help | Site Map

A97 variable length string declaration - how to do?

MLH
Guest
 
Posts: n/a
#1: Nov 13 '05
I'm working with lots of long strings now, it seems.
I have to import them & parse them constantly. The
A97 memo field type supports only 32768 chars.

What happens when this is processed...
Dim MyString As String
Am I getting VLS declaration or a FLS declaration?
Can I control which I get somehow?

I have done some homework, but I don't understand
my findings. Here's what I read in HELP...

There are two kinds of strings: variable-length and fixed-length
strings.

· A variable-length string can contain up to approximately 2
billion (2^31) characters.
· A fixed-length string can contain 1 to approximately 64K
(2^16) characters.

But it is not at all clear to me how to declare a variable-length
string VS a fixed-length string.

MLH
Guest
 
Posts: n/a
#2: Nov 13 '05

re: A97 variable length string declaration - how to do?


Testing, it seems that the Dim statement creates a var that will hold
millions of characters. Its not obvious whether Dim MyString As String
differentiates between variable-length strings or fixed-length strings
at the moment of declaring the var.

What is obvious is that the Dim statement creates a string var that
can be assigned string values of any length up to the maximum
handled by variable-length string variables (around 2 billion chars).

I still don't know if A97 allows programmer to specify the string
var type as fixed or variable length?
Les Desser
Guest
 
Posts: n/a
#3: Nov 13 '05

re: A97 variable length string declaration - how to do?


In article <ueerh19dnvv0uul9uln7u63nehgfn211r8@4ax.com>, MLH
<CRCI@NorthState.net> Tue, 6 Sep 2005 11:52:54 writes
[color=blue]
>Testing, it seems that the Dim statement creates a var that will hold
>millions of characters. Its not obvious whether Dim MyString As String
>differentiates between variable-length strings or fixed-length strings
>at the moment of declaring the var.
>
>What is obvious is that the Dim statement creates a string var that
>can be assigned string values of any length up to the maximum
>handled by variable-length string variables (around 2 billion chars).
>
>I still don't know if A97 allows programmer to specify the string
>var type as fixed or variable length?[/color]

Something like (I think)

Dim S As String * 100

I assume the reason why a fixed length string is limited to 64K is that
the length in the Dim statement is implemented as an Integer.
--
Les Desser
(The Reply-to address IS valid)
Albert D. Kallal
Guest
 
Posts: n/a
#4: Nov 13 '05

re: A97 variable length string declaration - how to do?


You can declare a fixed length as:

Dim s As String * 20

However, with modern systems, I can think of NO reason to use fixed length
strings

(about the ONLY exception I can think of is for custom export routines, and
even that is stretching it)

Those fixed length strings are really only there for compatibility with VERY
VERY old BASIC code.

Further, why use a fixed length one? They do NOT run faster, they do NOT
save memory, and really don't do anything for you except let old COBOL
programmers, and few others from 20 years ago work with fixed length string
variables, of which we now don't care about, and don't need.
[color=blue]
> What happens when this is processed...
> Dim MyString As String
> Am I getting VLS declaration or a FLS declaration?[/color]

You are getting a variable length one.

[color=blue]
> Can I control which I get somehow?[/color]

You can, but do you really need to?

There is a good number of string functions that you can use to pad, or add
spaces.

I mean, just make a handy global function to pad strings. You can use:

Public Function MyPad(s As String, intSize As Integer) As String

MyPad = Format(s, "!" & String(intSize, "@"))

End Function


Now, anywhere in code, you can go:

mypad("abc",20)

The above expression would return the string of "abc", but padded to 20
chars long

So, even for a custom export routine, I don't see the need to declare fixed
length strings.

For input processing, I see even LESS need for fixed length strings.

Perhaps you might expand on why, or what the reasons here are for needing
fixed length strings, but I am at a loss here as why you need a fixed length
variable?

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com
http://www.members.shaw.ca/AlbertKallal


MLH
Guest
 
Posts: n/a
#5: Nov 13 '05

re: A97 variable length string declaration - how to do?


Thx to you both. I agree. I don't see any
real need to burden myself dealing with
fixed length strings.

My real concern was whether or not I had
to do anything special to ensure I was dim'ing
string vars correctly (to handle VLS's. Thx!
Albert D. Kallal
Guest
 
Posts: n/a
#6: Nov 13 '05

re: A97 variable length string declaration - how to do?


"MLH" <CRCI@NorthState.net> wrote in message
news:ru2uh1pkakh909ot3roge6ae95g1g9ca1s@4ax.com...[color=blue]
> Thx to you both. I agree. I don't see any
> real need to burden myself dealing with
> fixed length strings.
>
> My real concern was whether or not I had
> to do anything special to ensure I was dim'ing
> string vars correctly (to handle VLS's. Thx![/color]

On a lot of systems, fixed length strings run a LOT faster! (many times in
fact!!). However, VB or in our case VBA this is NOT the case.

So, your asking about how to use fixed length strings is very often a fair
question. It is a question that I took serous, despite it not having any
bearing in ms-access. So, often as a developer you will want to know if
fixed length variables are available, as they often can run MANY times
faster then VLS.

For some reason, in VB, or VBA, fixed length strings don't seem to change
performance at all, and in fact I seen them slow things down. So, I am
actually of the beliefs that those fixed length strings are "faked" by
ms-access in some fashion, and only put in for compatibility of old basic
code....


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com
http://www.members.shaw.ca/AlbertKallal


Closed Thread