Announcement

Collapse
No announcement yet.

Parameter-passing Help

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

    Parameter-passing Help

    I wrote the following script, which I thought would return a msgbox which says "y=Yadda Yadda". Instead, it returns "y=".

    What am I doing wrong?

    [This message was edited by Mechanic on Monday, 18 February 2002 at 05:55 PM.]

    #2
    You set "Yadda yadda" to X, but never to saveLyrics itself, and therefore, to its return value.

    Nucleus Home Automation
    News, support, and updates for Rover, Network Monitor, TimeIcons, and more

    Comment


      #3
      I looked at that for so long, I couldn't see it.

      How about this:

      If I move the code around so it looks like this:
      My function isn't working because the variable "Z" no longer equals "LA LA LA" by the time we get to the script. How do I get the contents of Z to carry into the script? In the real ASP, Z is derived from over 200 lines of code.

      [This message was edited by Mechanic on Monday, 18 February 2002 at 09:36 PM.]

      Comment


        #4
        Some of the script you're using runs on the server, and some on the client. The stuff inside <% %> never gets to the client. You can make Z carry over to the client by replacing it with <%= Z %>. (When you View Source on the client, you still won't see that 200 lines nor will you see the variable name Z, but you will see its value.)

        Nucleus Home Automation
        News, support, and updates for Rover, Network Monitor, TimeIcons, and more

        Comment


          #5
          Thanks, this is great stuff, I'd heard this before, but now I'm actually starting to understand it. [img]/infopop/emoticons/icon_biggrin.gif[/img]

          Using your code in my example above, <%=Z%> works perfectly. For the REAL code I'm writing, however, "Z" contains 20-50 lines of information, with CR/LF at the end of each line. If I attempt to put "msgbox "<%=Z%>" when Z contains CR/LF combinations, it is rendered in the browser as:

          Line 1: msgbox "Now is the time,
          Line 2: For all good men
          Line 3: To come to the aid..."

          Which generates an "Unterminated String" error on Line 1.

          Ideas?

          [This message was edited by Mechanic on Tuesday, 19 February 2002 at 08:45 PM.]

          Comment


            #6
            Note that ASP pages are set to not display dialogs when executing script. So you cannot use the msgbox function.

            -Rich
            💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

            Comment


              #7
              ...you might need to convert Z into something acceptable to whatever you're using it in. E.g., if it were really a MsgBox command, you might need to convert end-of-line markers into the string " & vbCrLf & " (except the last one).

              Nucleus Home Automation
              News, support, and updates for Rover, Network Monitor, TimeIcons, and more

              Comment


                #8
                Rich - I guess I could have picked a better example. I'm trying to write all this to a database, not a msgbox. I was using the msgbox as a simple tester. I'd noted the restriction without understanding it. Makes sense.

                Hunter - I wish there was a simple way to provide an example, because I'm having a hard time believing that this is really as difficult as it seems. My code works as long as it's executed server-side. As soon as I use Response.write or the <%=%> format you described, it messes up on the CRLFs.

                Do the client-side and server-side engines treat the contents of variables differently? Or is that HS treats it the way I want, and IE doesn't?

                Anyway, thanks for all the help.

                Regards,

                Bill

                Comment


                  #9
                  Can you give a rough description of what this whole thing is supposed to do?

                  My best guess is this: the server gets and reformats some lyrics and uses them to build a web page. On the page you want a button which saves those lyrics to a database somewhere -- I'm not sure if you're looking to save it on the server or on the client.

                  If that's accurate, then the problem here seems to be a question of passing the lyrics back and forth. The server gets the lyrics and sends them to the client by simply putting them into the web page. But what does the client do with them?

                  If you want the lyrics saved on the client, probably the easiest way is to make it so that the server-side script doesn't just include the lyrics (with <%= Z %> ) but actually converts them into bits of actual program code, part of the client-side script. For instance, let's imagine a very short song:

                  Roses are red, violets are blue,
                  HomeSeer is nifty, and ASP too.

                  (Okay, I'm no poet.) What you will need your client-side script, designed to save this into a file, to look like, is something like this:

                  x = "Roses are red, violets are blue," & vbCrLf & "HomeSeer is nifty, and ASP too."

                  So your server-side script needs to be written so that it is essentially generating that line of code that will become part of the client-side script. Then the rest of the client-side script operates on that variable.

                  That's not the only way to do this but it's probably one of the easier ways.

                  Nucleus Home Automation
                  News, support, and updates for Rover, Network Monitor, TimeIcons, and more

                  Comment


                    #10
                    Your CRLF solution seems to make sense. All I'd have to do is write a procedure to go through every character of the Lyrics variable and look for CFLF combinations and replace them with "&vbCRLF&". Got it.

                    You have the scenario nailed: The page in question goes out to the WWW and finds song lyrics (Lyrics=hs.GetURL). So Lyrics contains the whole web page. Then the page is stripped down until only the lyrics remain.

                    Now I want to show the lyrics to the user, and let the user choose whether to save them into the database back on the HS server. That's why the lyrics end up getting passed back and forth between the server and client.

                    This seemed like an easy project when I started it....

                    Comment


                      #11
                      I am jumping in the middle here so, I may be way off track but

                      how about using geturl to get the lyrics back after they are writen to NPLyrics??

                      e.g. Open NPLyrics download the lyrics to NPLyrics and then do a geturl on NPLyrics.

                      Or maybe (better) save the Lyrics to a system or virtual device and then recall them?
                      DSteiNeuro

                      HS3Pro

                      MSI Cubi Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz, 2201 Mhz, 2 Core(s), 4 Logical Processor(s) 16GB DDRl RAM

                      Enabled Plug-Ins
                      BLRussound, BLSpeech, HSTouch Server, JowiHue, MyQ, Nest, Rain8, Squeezebox, Ultra1Wire3, UltraGCIR3, Vista Alarm, X10,Z-Wave

                      Comment


                        #12
                        If the lyrics are going to be saved on the server end, it might be easier, unless bandwidth is scarce, to just have all the work happen on the server. Trying to send the lyrics from the server to the client and then back is a lot more work than it's worth. Overall I'd say having a client-side script that actually does the save is making things too hard.

                        Instead, I'd do one of two things. First, have the server-side script store the lyrics in a file or variable somewhere; then have the "save" link or button just instruct it to move from there into the permanent storage location. Second, don't save it at all; have the "save" link go back into the same page only with a flag set that makes it save it (and not show the save link again).

                        Either way, it's a Simple Matter Of Programming. [img]/infopop/emoticons/icon_wink.gif[/img]

                        Nucleus Home Automation
                        News, support, and updates for Rover, Network Monitor, TimeIcons, and more

                        Comment


                          #13
                          D- Feel free to jump in with both feet. It's kinda deep, though. Your suggestion is on my list of things to try.

                          Hunter - Very Funny! I needed that.

                          That's a more elegant way than the way it is now. The way it is now is that the SAVE button invokes a new page that is a copy of the original, but with the database UPDATE statement at the end. This is pretty much the same thing, but without duplicate pages.

                          I was trying to avoid a refresh, but I can't see any way around it now. The whole problem here is that once the server has processed the page, it's gone. I was getting pretty good at HTML, but ASP offers enough difference that it's kicking my ASP!

                          Thanks,

                          Comment


                            #14
                            The form self-references, then detects the save status via QueryString.

                            Posted for your reference.

                            Thanks again for all the help.

                            Comment

                            Working...
                            X