Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PRINT USING command very buggy in FB
#1
I am finding that PRINT USING does not work very well with user data types in FB. Specifically, printing string variables to occupy a certain number of spaces regardless of length.

If you use normal variables, it works fine, like this:

Print Using "\ \ 12345";"ab"
Print Using "\ \ 12345";"abcd"

Input "Hit Enter to end",a$

On both lines the 12345 line up right under each other, even though the two strings are different lengths. Just as Print Using is supposed to do.

But if you do it this way:

Type info
firstname As String *10
End Type

Dim person1 As info
Dim person2 As info

person1.firstname="Jim"
person2.firstname="Charles"

Print Using "\ \ Smith";person1.firstname
Print Using "\ \ Smith";person2.firstname

Input "Hit Enter to end",a$


..the two "Smith"'s do NOT line up above each other, as they should. Even though the backslash characters should cause the user data type string variables to print in the same space, they don't. The different length seems to create some sort of problem.

This never occurred under QuickBasic. Does anyone know why this is happening?
Reply
#2
I agree with you.
I posted a thread a week or so ago called "Strange results in FB with Print Using" on this same forum called FB Programming Help.
As you can see, I got nowhere.
Good luck.
*****
Reply
#3
From a bit of testing it seems that it has something to do with PRINT USING not handling null characters very well. Because FB tacks on nulls to user-data-strings in order to fill out their length in the field (string * 10 or whatever), trying to print that string becomes problematic with Print-Using. Normal Print works just fine, as does print-using if you use the & marker instead of the \\'s. But of course that's useless if you want to format the line uniformly.

Original QB added spaces instead of nulls, which printed correctly. While I do appreciate the change to nulls, in order to making straight printing of the string easier (without having to use RTRIM$), the handling needs to be fixed big time in the next version.
Reply
#4
I tried both 0.14 and 0.15 (CVS) and the example you gave lines up both "Smith".

Regards,
Mark
Reply
#5
I don't know why those backslashes got shoved so close together when I hit Submit. Try it lke this, with them further apart but still the same distance, and you'll get a different result.

Type info
firstname As String *10
End Type

Dim person1 As info
Dim person2 As info

person1.firstname="Jim"
person2.firstname="Charles"

Print Using "\ \ Smith";person1.firstname
Print Using "\ \ Smith";person2.firstname

Input "Hit Enter to end",a$
Reply
#6
Ugh. No matter how many spaces I put between the backslashes (\ \) in the example, they get squished down to only one or two spaces when I submit the message. Try manually putting about 12 spaces between the backslashes, and you'll get a different result.
Reply
#7
Use code tags:
Code:
\               \
or
Code:
[code]...[/code]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)