Web Analytics Made Easy -
StatCounter multi-line variable? - CodingForum

Announcement

Collapse
No announcement yet.

multi-line variable?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • multi-line variable?

    Is there a way to declare a multi-line variable?

    i.e.:

    var fig = "adding text here but will span onto next line " *symbol*
    "continuing to add text here but part of same variable."

    is that possible? Should I just make it an array?
    ----------------
    Ben Scofield
    http://www.scofield.cc/pipes/ (under construction)

  • #2
    What's wrong with one line
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

    Comment


    • #3
      var fig = "adding text here but will span onto next line "+
      "continuing to add text here but part of same variable."


      .....Willy

      Comment


      • #4
        willy, javascript really wants all statements to carry on one line and to end in a semi-colon, otherwise it can break in certain browsers. ie:

        var strFoobar = "this is foo is foo is foo" ;

        and not ...

        var strFoobar = "this is foo" +
        "is foo" +
        "is foo"

        ------------------------

        geddit?
        Last edited by jbot; Feb 12, 2004, 10:58 AM.
        *keep it simple (TM)

        Comment


        • #5
          I'm creating the *.js file that I'm using from another program & another programming language. In the programming language that I'm using a variable can only contain 1000 characters. So I have switched to an array there. But the way it writes files is line by line, so each line of the *.js file I write will contain the data that I would like to be in a variable. But it's too big for me to just say:

          var jsvariable = myvar //because myvar >1000 for my language.

          so I have:

          var jsvariable = myarray[5] //becuase I can hold infinite data here.

          but can I do:

          var jsvariable = myarray[1] thru myarray[5] ??

          not sure if that made sense or not.

          well jbot and willy disagree...

          anyone else wanna chime in?
          ----------------
          Ben Scofield
          http://www.scofield.cc/pipes/ (under construction)

          Comment


          • #6
            AND THE WINNER IS.....


            WILLY!!!


            Tried breaking the line up into multiple lines using + and it worked like a charm. Thanks.
            ----------------
            Ben Scofield
            http://www.scofield.cc/pipes/ (under construction)

            Comment


            • #7
              Why must you break it up into lines? Remember, word wrap is not the same as a hard return. You could even put your entire document on a single line if you wanted to, providing you use semicolons to separate multiple javascript statements on the same line.
              Go to:
              http://www.TailsArchive.net/
              http://xfox.proboards21.com/

              Comment


              • #8
                Can't break it up into lines because of 2 facts:

                1- I MUST use an array to store data because variables in my coding language (that I use to generate the javascript file) only allows me to store 1000 characters into a variable.

                2- I CANNOT write the contents of the entire array to one line of the javascript file (the end product) because my write command in this programming language writes one line at a time.

                So I would have to have a for loop to empty out the array, but I cannot empty it out into a variable (too small) so I must start placing the conents of it into the file. But fact 2 states that my function to write to file rights a line at a time. So everytime it would move onto a new element in the array it would have written the previous element onto the previous line.

                example:

                arraysize=array.length
                for cnt=1 to arraysize
                write to javascript from array[cnt]
                end for

                each time through the loop writes a line. Now I'm adding on + characters and ; to end it.
                Last edited by Codin_away; Feb 12, 2004, 02:27 PM.
                ----------------
                Ben Scofield
                http://www.scofield.cc/pipes/ (under construction)

                Comment


                • #9
                  Originally posted by jbot
                  willy, javascript really wants all statements to carry on one line and to end in a semi-colon, otherwise it can break in certain browsers. ie:

                  var strFoobar = "this is foo is foo is foo" ;

                  and not ...

                  var strFoobar = "this is foo" +
                  "is foo" +
                  "is foo"

                  ------------------------

                  geddit?
                  jbot;

                  I did not say nor imply that I condoned splitting the variable across multiple lines. I merely answered the question which was posed.

                  Sometimes people have reasons for doing something even if I do not agree with them.

                  Anyway, Which browser(s) break because of breaking a line?
                  I'm no expert, but I have never seen this.....

                  .....Willy

                  Comment


                  • #10
                    I'm in a controlled environment, this is not for internet use. I'll be able to determine which browsers are used.
                    ----------------
                    Ben Scofield
                    http://www.scofield.cc/pipes/ (under construction)

                    Comment


                    • #11
                      Codin_away

                      I only was asking because jbot spoke with authority and I was curious which browsers are known to break.

                      .....Willy

                      Comment


                      • #12
                        i figured... I posted that in response to jbot, before reading your reply.
                        ----------------
                        Ben Scofield
                        http://www.scofield.cc/pipes/ (under construction)

                        Comment


                        • #13
                          Better that using "+", just escape the line break...

                          var myvar="This is foo\
                          is foo\
                          is foo";

                          As far as i no this works in all browsers.

                          Comment

                          Working...
                          X