Announcement

Collapse
No announcement yet.

How can I come back to next line code after a sc_redir ??

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

  • How can I come back to next line code after a sc_redir ??

    Dear all,
    I got a php code connected to a button (send e-mail) and within the code I would like to use a sc_redir to run a pdf repord application passing to it a parameter.
    I wonder if it's possible , once run the pdf report, come back to next line of code to carry on with it. The pdf report makes a pdf file that I wont later to
    attach to a mail .
    Thanks

  • #2
    Nope - it's a one-time deal. sc_redir() is not actually a "call" (more like an old style GOTO). It transfers control completely to the app you have directed it to (any lines after an sc_redir will NEVER get executed - unless wrapped in conditional code like below).

    The workaround is to bounce around different apps using sc_redir, but maintain status information using global variables that the calling app can check to determine which bits of code in whatever events should run.

    Something like:

    In the calling app set up an "out" global var named [status] in onApplicationInit, and set it as "initial".

    Then set up a status check in onLoad:

    Code:
    if ([status] == "initial") {
       //   
       // Do some initial processing here, and then redirect to other app
       //
       sc_redir(other_app);
    
    } else if ([status] == "after_redir") {
       //
       // do your after a redir processing here...
       //
    } else if (...
    Then in the app you re-direct to (other_app), when it's done whatever it needed to do, add:

    Code:
    [status] = "after_redir";
    sc_redir(original_calling_app);

    Comment


    • #3
      ^
      |
      |

      This
      /Giuseppe

      Professional Scriptcase Services
      Some Customers opinions

      Comment


      • #4
        Hello Adz and Giu,
        thanks for hint. It's a bit complicated to manage but if it's the only way I will try.

        I wonder also if it possible to run an application on background mode but I suppose it's not so easy too.
        For istance I got the pdf report set on server that save the pdf file produced on a certain directory.
        I got always the message when it finish that say .... Pdf generation terminated .... if you like to come back to previous application....
        I've still not found the way to hide it .... ;-(((

        Comment


        • #5
          Originally posted by giovannino View Post
          Hello Adz and Giu,
          thanks for hint. It's a bit complicated to manage but if it's the only way I will try.

          I wonder also if it possible to run an application on background mode but I suppose it's not so easy too.
          For istance I got the pdf report set on server that save the pdf file produced on a certain directory.
          I got always the message when it finish that say .... Pdf generation terminated .... if you like to come back to previous application....
          I've still not found the way to hide it .... ;-(((
          In php there's no background mode. You can run php in a cron for instance, but then you have no interactivity with the end-user: you cannot use screens. One option might be to create the pdf fully in your (control) application if that's applicable. It requires a lot of manual code, but you are in full control.
          Albert Drent
          aducom software netherlands
          scriptcase partner, reseller, support and (turn-key) development
          www.scriptcase.eu / www.scriptcase.nl

          Comment


          • #6
            Ok .... I don't know a lot of things....;-)

            No hints about hiding the default end of pdf generation message ?
            I mean something like sc_exit(sel) that hide the Ok buttton.
            I suppose that if you have set "PDF Destination" you haven't any control

            Comment


            • #7
              I solved using iReport & JasperStarter. You can create a "one-statementent-function" that create the report inside your control/app.
              Giorgio Bravi
              Dolphin Software & Thinkware
              www.dolphin.it

              Comment


              • #8
                Hi Giorgio !!
                Yes, probably it's the best solution but I got only this Order Form and I don't want to loose time on studying ... another sw solution. My brain ... is overcharged.... ;-) and I got only some free bits to use .... ;-) Lastly I need to put on agenda... at midday .. remember to eat something .... ;-) Thanks ... Bye

                Comment


                • #9
                  Didn't readed all the post, but, did you thought about do a "GET" to the PDF application with cURL, instead of redir?

                  http://php.net/manual/es/book.curl.php
                  /Giuseppe

                  Professional Scriptcase Services
                  Some Customers opinions

                  Comment


                  • #10
                    Thanks Giu but for me it's a too advanced level to use this library.

                    Comment


                    • #11
                      Googling I founded this


                      popen("./myscript.php", "w");

                      Does it make sense ?
                      is the problem Always the return to php code ?

                      Comment


                      • #12
                        what you realy want is to call a subroutine (function) which will return to the next sentence. But as soon as you do a redir you are giving control to another phpfile. In some cases you can do a call to a php program and the load the result of that program and continue to the next line. That's used in calling webservices or rest services and where curl comes in although there are other solutions. But scriptcase modules are not designed that way, they are just regular applications. I don't see the point of the popen. It will open a php file in write modus (...)
                        Albert Drent
                        aducom software netherlands
                        scriptcase partner, reseller, support and (turn-key) development
                        www.scriptcase.eu / www.scriptcase.nl

                        Comment

                        Working...
                        X