Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fixed STRING variables or better say semi-variables
#1
Hi friends
here I share just some thinking about variable of type STRING and of FIXED lenght

in QBasic and in QB64 is possible to create variables of type STRING with a fixed lenght.
wiki di STRING

There is some little differences between STRING and FIXED STRING.
1. The last type cannot be initializated as a void string o null string because it must keep its fixed dimension.
2. the fixed string cannot add value in tail because it must keep its fixed dimension
so in runtime it cannot recursively modify itself 

please run this code to get the experience of this behaviour
Code: (Select All)

Dim a As String * 8, b As String, c As String * 2, d As Integer
' initialization to a void/null string
a = ""
b = ""
c = ""
Print "    a          c            b"
Print ">" + a + "<", ">" + c + "<", ">" + b + "<"

' filling the string variable
For d = 1 To 10
    a = a + LTrim$(Str$(d))
    c = c + LTrim$(Str$(d))
    b = b + LTrim$(Str$(d))
Next d
Print ">" + a + "<", ">" + c + "<", ">" + b + "<"
End

Can be this enough interesting to note into wiki of STRING?

thanks for feedbacks
Reply
#2
You can fill them to capacity with MID$...

Code: (Select All)

Dim a As String * 8, b As String, c As String * 2, d As Integer
' initialization to a void/null string
Print "    a          c            b"
Print ">" + a + "<", ">" + c + "<", ">" + b + "<"

' filling the string variable
For d = 1 To 10
    Mid$(a, d, 1) = LTrim$(Str$(d))
    Mid$(c, d, 1) = LTrim$(Str$(d))
    b = b + LTrim$(Str$(d))
Next d
Print ">" + a + "<", ">" + c + "<", ">" + b + "<"
End

Pete

- I took an IQ test. The results show I 'm re-gifted.
Reply




Users browsing this thread: 1 Guest(s)