Discussion:
forcing carriage returns when writing into a text field in director 7
(too old to reply)
Reify32207
2008-04-27 21:57:20 UTC
Permalink
I am trying to put together a data table in a text field in director 7. I have
a 4 variables that contain random numbers. I would like my data table to
appear in the following format:

P1 xxx atm
V1 xxx mL
P2 xxx atm
V2 xxx mL

I was trying to do it into a single text field by concatenating the text
string for the variable name, the variable, and also the variables containing
the units. Unfortunately, the different units are all different lengths, so I
keep getting word wrap issues. Is there anything I can do to just tell it to
start a new line?

My workaround was to put each line into a different field, but .....

Any help would be appreciated.

BobR
Sean Wilson
2008-04-27 22:14:26 UTC
Permalink
I'm not sure I understand correctly, but you can use the RETURN constant
like so:
aString = "this is a line of text,"
aString = aString & RETURN & "and this is another."
member("text").text = aString
Darrel Hoffman
2008-04-28 15:30:09 UTC
Permalink
This is actually fairly simple when working with numbers, because numbers
(in most fonts) are fixed-width. X number of digits will take up Y amount
of space, regardless of what those digits are. Thus, if you figure out the
maximum number of digits that will fit into your column, you can count the
digits of your random number to see if it'll fit, and then add RETURNs in it
if it won't. Another thing you can do if it fits your style is pad the
numbers with leading 0's. _'s are also usually the same width as numbers.
At any rate, it's a little hard to help if we don't have a good idea of what
kind of data you're trying to display - what's the range of numbers, for
example? If you know about how many digits you'll have in your longest
numbers, you should be able to tailor your text member to be able to fit
that many digits without wrapping, just by typing in 12345678 or however
many digits you need and stretching things to fit that. It gets a good deal
trickier with letters, unfortunately - "woman" takes up more space than
"illicit" despite containing 2 fewer letters. There's ways of dealing with
that, but they're not easy...
Reify32207
2008-04-28 16:23:48 UTC
Permalink
ok, the &return& worked like a champ. I saw that in the lingo dictionary, but
could not make sense of it while exhausted.

I am guessing that Darrel's reply would be useful for making the table line up
into columns, though I am not that anal about it (yet)

Thanks to both of you.

BobR
Darrel Hoffman
2008-04-28 16:54:45 UTC
Permalink
Post by Reify32207
ok, the &return& worked like a champ. I saw that in the lingo dictionary, but
could not make sense of it while exhausted.
I am guessing that Darrel's reply would be useful for making the table line up
into columns, though I am not that anal about it (yet)
You can also use tabs in the text member to get things to line up, once you
do decide to get that anal. I'm actually working on something very similar
right now, so I know a bit about what you're going through...
Xposure Interactive
2009-03-19 11:23:15 UTC
Permalink
What on earth am I doing wrong? I know it will be something obvious but I can't
for the life of me spot it!

on createFile
gDatabase = "Forename :" && gName1 & RETURN & "Surname :" && gName2
myFile = new (Xtra "fileio")
filename = the moviePath & "records\" & gName1 & gName2 & ".txt"
createFile (myFile,filename)
openFile (myFile,filename, 0)
writeString(myFile,string(gDatabase))
myFile = 0
end
Andrew Morton
2009-03-19 11:43:54 UTC
Permalink
Post by Xposure Interactive
What on earth am I doing wrong? I know it will be something obvious
but I can't for the life of me spot it!
on createFile
gDatabase = "Forename :" && gName1 & RETURN & "Surname :" && gName2
myFile = new (Xtra "fileio")
filename = the moviePath & "records\" & gName1 & gName2 & ".txt"
createFile (myFile,filename)
openFile (myFile,filename, 0)
writeString(myFile,string(gDatabase))
myFile = 0
end
You haven't said what is/is not happening that you consider to be wrong, but
1) you've forgotten to closeFile
2) you've forgotten to check for errors at each step of using FileIO
3) gDatabase is already a string, or if you have a function called string
that it a bad idea as string is a reserved word in Lingo.
4) RETURN in Lingo only generates a LF character. Some text editors don't
regard that as an end-of-line. You will need to use numtochar(13) &
numtochar(10) for Notepad to show a new line.

HTH

Andrew
Xposure Interactive
2009-03-19 13:01:54 UTC
Permalink
Post by Andrew Morton
You haven't said what is/is not happening that you consider to be wrong, but
1) you've forgotten to closeFile
2) you've forgotten to check for errors at each step of using FileIO
3) gDatabase is already a string, or if you have a function called string
that it a bad idea as string is a reserved word in Lingo.
4) RETURN in Lingo only generates a LF character. Some text editors don't
regard that as an end-of-line. You will need to use numtochar(13) &
numtochar(10) for Notepad to show a new line.
HTH
Andrew
The problem is that the string doesn't add a carriage return. It just adds a
square.
Mike Blaustein
2009-03-19 13:13:46 UTC
Permalink
Post by Xposure Interactive
The problem is that the string doesn't add a carriage return. It just adds a
square.
Then the answer is number 4 from Andrew's message.
Xposure Interactive
2009-03-19 13:22:35 UTC
Permalink
[q][i]Originally posted by: [b][b]Xposure Interactive[/b][/b][/i]
The problem is that the string doesn't add a carriage return. It just adds a
square.[/q]

Actually it prints with the carriage return.
Mike Blaustein
2009-03-19 13:46:19 UTC
Permalink
Post by Xposure Interactive
[q][i]Originally posted by: [b][b]Xposure Interactive[/b][/b][/i]
The problem is that the string doesn't add a carriage return. It just adds a
square.[/q]
Actually it prints with the carriage return.
You will also find that it displays with the carriage return correct in
pretty much every text editor out there... WordPad, Word, etc. Just
change the way you use the RETURN character...

Instead of this:

gDatabase = "Forename :" && gName1 & RETURN & "Surname :" && gName2

You would use this:

winReturn=numtochar(13) & numtochar(10)
gDatabase = "Forename :" && gName1 & winReturn & "Surname :" && gName2
Loading...