Announcement

Collapse
No announcement yet.

Custom Libraries & Macro

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

  • Custom Libraries & Macro

    i have a working code and it worked well when i run in AppInit event
    sc_select(rs, "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'my_DB' AND TABLE_NAME = 'my_TABLE';");
    if ({rs} === false) {
    echo "Access error. Message =". {rs_erro};
    } else {
    while (!$rs->EOF) {
    echo $rs->fields[0] . "<br>";
    $rs->MoveNext();
    }
    $rs->Close();
    }
    But when i copy and pasted it into my custom libary files, the application return a blank page.
    Is it true that macro can never be call in custom library?

    Thanks for the clarifications

  • #2
    Originally posted by weilies View Post
    i have a working code and it worked well when i run in AppInit event


    But when i copy and pasted it into my custom libary files, the application return a blank page.
    Is it true that macro can never be call in custom library?

    Thanks for the clarifications
    No, you can use macro's, we do it all the time. But the same rules for the macro's apply when you call them from an event. In your screenshot there's a syntax error as there's a {} mismatch, but that can be a copy error. Useually the problem might be that you haven't changed your code into a procedure/function or that you have a ; behind the function declaration.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      hi Albert, i tried a few times, the same code block below executed in AppInit event and it's working fine but when i cut & paste it into a custom library class, it will return me a blank screen.

      here is the code block. No typo error
      sc_select(rs, " SELECT COLUMN_NAME
      FROM INFORMATION_SCHEMA.COLUMNS
      WHERE TABLE_SCHEMA = 'astudion_virtualdesk'
      AND TABLE_NAME = 'country';");

      if ({rs} === false) {
      echo "Access error. Message =". {rs_erro};
      } else {
      while (!$rs->EOF) {
      echo $rs->fields[0] . "<br>";
      $rs->MoveNext();
      }
      $rs->Close();

      Comment


      • #4
        You have to put this routine in a function and call the function. So I can't tell regarding this code-snippet. But there's something wrong in the generated code so you should look into the generated code to see what's going on.
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          here the errors i got from hosting
          [03-Oct-2014 03:35:14 America/Denver] PHP Fatal error: Call to undefined function sc_select() in /home4/astudion/public_html/sc.astudion.com/sc8/app/VirtualDesk/PersonPersonality/ExSQL.php on line 33

          what i understand here is sc simply cant recognize the sc func if i put it in a class

          Comment


          • #6
            Originally posted by weilies View Post
            here the errors i got from hosting
            [03-Oct-2014 03:35:14 America/Denver] PHP Fatal error: Call to undefined function sc_select() in /home4/astudion/public_html/sc.astudion.com/sc8/app/VirtualDesk/PersonPersonality/ExSQL.php on line 33

            what i understand here is sc simply cant recognize the sc func if i put it in a class
            I don't know, I use the library for storing functions and they contain loads of sc_ functions and there are no issues. For classes I don't know.
            Albert Drent
            aducom software netherlands
            scriptcase partner, reseller, support and (turn-key) development
            www.scriptcase.eu / www.scriptcase.nl

            Comment


            • #7
              maybe a silly question - but you have in Programming | Libraries - ticked the library in question in the app in question?

              Comment


              • #8
                Yup, at first I thought I was as silly as that... but I checked

                Comment


                • #9
                  hi Albert,

                  The same code i executed in onApplicationInit, no error.
                  But when i move it to a PHP function (as attched image), it throws me error

                  i wonder how u able to run it without error... could it because you using SC7?
                  Attached Files

                  Comment


                  • #10
                    hi Albert,

                    i managed to found ur old post
                    http://www.scriptcase.net/forum/arch...hp/t-3310.html

                    looks like it's a known bug and does they resolved it already?
                    not to say sc_select, it doesn't work even i try call sc_alert in my custom library


                    having the macro in function worked. But it's only within the app itself, i would need my method to be re-usable, so i rather put in libraries.

                    Plz let me know if SC team has already resolved the bug.

                    Thanks
                    Last edited by weilies; 10-04-2014, 10:23 PM.

                    Comment


                    • #11
                      If you look at my code there's a invalid ';' at the end of the function name. Removing it solved my issues. But look also at the scope of the macro, as this is vital. You can put anything in your library, but it depends on the moment where you call it if the macro can be found.
                      Albert Drent
                      aducom software netherlands
                      scriptcase partner, reseller, support and (turn-key) development
                      www.scriptcase.eu / www.scriptcase.nl

                      Comment


                      • #12
                        hi, i have composed the step-by-step with link below
                        https://docs.google.com/document/d/1...it?usp=sharing

                        plz tell me if i have any missing steps which cause the macro failed in library

                        Thanks in million

                        Comment


                        • #13
                          I don't know, appearantly you can't use classes. I never do.
                          Albert Drent
                          aducom software netherlands
                          scriptcase partner, reseller, support and (turn-key) development
                          www.scriptcase.eu / www.scriptcase.nl

                          Comment


                          • #14
                            The other thing maybe to try is the:

                            sc_include(xxx.php);

                            Add that in the onApplicationInit event of the app that calls that library (library still needs to be checked in Programming | Libraries.

                            Comment


                            • #15
                              hi adz1111,

                              It doesn't work with sc_include
                              But nice try.

                              Thanks

                              Comment

                              Working...
                              X