10 Replies Latest reply on Mar 19, 2009 6:46 AM by Newsgroup_User

    forcing carriage returns when writing into a text field in director 7

    Reify32207
      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

        • 1. Re: forcing carriage returns when writing into a text field   in   director 7
          Level 7
          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
          • 2. Re: forcing carriage returns when writing into a text field in director 7
            Level 7
            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...


            • 3. Re: forcing carriage returns when writing into a text field in director 7
              Reify32207 Level 1
              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
              • 4. Re: forcing carriage returns when writing into a text field in director 7
                Level 7
                > 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...


                • 5. Re: forcing carriage returns when writing into a text field in director 7
                  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
                  • 6. Re: forcing carriage returns when writing into a text field in director 7
                    Level 7
                    Xposure Interactive wrote:
                    > 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


                    • 7. Re: forcing carriage returns when writing into a text field in director 7
                      Xposure Interactive Level 1
                      > 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.
                      • 8. Re: forcing carriage returns when writing into a text   field in   director 7
                        Level 7
                        Xposure Interactive wrote:

                        > 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.
                        • 9. Re: forcing carriage returns when writing into a text field in director 7
                          Xposure Interactive Level 1
                          quote:

                          Originally posted by: Xposure Interactive
                          The problem is that the string doesn't add a carriage return. It just adds a square.


                          Actually it prints with the carriage return.

                          • 10. Re: forcing carriage returns when writing into a text   field in   director 7
                            Level 7
                            Xposure Interactive wrote:
                            >
                            quote:

                            Originally posted by: Xposure Interactive
                            > The problem is that the string doesn't add a carriage return. It just adds a
                            > square.

                            >
                            > 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