Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Javascript server-side

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

    Javascript server-side

    I saw the presentation of roadmap 2014, and the following code is presented as a new Alpha feature.
    But it is not possible to execute it in Alpha 12v3.5.

    When Alpha release the javascript server-side feature?

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta name="generator" content="Alpha Anywhere HTML Editor Version 12 Build 2689-4440">
    <!-- must use in order to make XP Themes render -->
    <meta HTTP-EQUIV="MSThemeCompatible" content="Yes" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    
    <title>SQL from Javascript</title>
    </head>
    <body>
    <p>The code block on this page is server-side javascript</p>
    
    <a5%
    debugger;
    var country = request.variables.country;
    if(typeof country === 'undefined') country='uk';
    var a5 = AlphaAnywhere;
    var cn = new a5.sql.connection();
    var args = new a5.sql.arguments();
    args.add('whatCountry',country);
    var cs = '::Name::northwind';
    var flag = cn.open(cs);
    print('Connection was opened:'+flag+'<br><br>');
    var sql = "select * from customers where country = :whatCountry";
    flag = cn.execute(sql.args);
    if(flag === false) {
    	print('error executing sql');
    } else {
    	var rs = cn.resultset;
    	var flag = rs.nextRow();
    	var count = 0;
    	var arr = [];
    	debugger;
    	while(flag){
    		count = count + 1;
    		arr.push('<p>'+rs.data("customerId")+'</p>');
    		flag = rs.nextRow();
    	}
    	var html = arr.join('');
    	print(html);
    	print('<br><br>');
    	print('rows in query:'+count);
    }
    cn.close();
    %>
    
    </body>
    </html>

    #2
    Re: Javascript server-side

    Yes this is important question.

    The updated summary of Roadmap 2014 is here

    If you read the roadmap there is lot of plans in Server-side Roadmap to bring javascript available (as in first post example) but as we can now see plans are just plans.

    Also it is good to notice that the Deployment Road-map has just two things: IIS and Alpha Cloud.

    IIS has tight integration with ASP.net so I suppose V8 support is coming through asp.net or is it?

    We can already run server side javascript with Nodejs. I wonder does IIS integration has any impact to this feature.

    Comment


      #3
      Re: Javascript server-side

      The IIS integration is very important, I agree.

      We can already run server side javascript with Nodejs
      We can call Node functions using V8, but the code isn't integrated with Alpha workspace like in the example.

      Thanks.

      Comment


        #4
        Re: Javascript server-side

        Originally posted by tiago View Post
        We can call Node functions using V8, but the code isn't integrated with Alpha workspace like in the example.
        Thanks.
        If you read again my first post that was what I was trying to underline (with no success).

        Comment


          #5
          Re: Javascript server-side

          the code shown in post #1 almost looks like an ajaxCallback xbasic code (except for using var for dimming and == or === for equality checking), what is the difference or advantage?
          thanks for reading

          gandhi

          version 11 3381 - 4096
          mysql backend
          http://www.alphawebprogramming.blogspot.com
          [email protected]
          Skype:[email protected]
          1 914 924 5171

          Comment


            #6
            Re: Javascript server-side

            Originally posted by GGandhi View Post
            the code shown in post #1 almost looks like an ajaxCallback xbasic code (except for using var for dimming and == or === for equality checking), what is the difference or advantage?
            If you can code server-side and client-side using javascript, you only need to know one language (as opposed to needing to know both javascript and xBasic.) It also leverages existing knowledge for those users who may be coming from a Node.js background to Alpha Anywhere. It also allows users to leverage any and all Node.js modules that are out there.

            Originally posted by tiago View Post
            I saw the presentation of roadmap 2014, and the following code is presented as a new Alpha feature.
            But it is not possible to execute it in Alpha 12v3.5.

            When Alpha release the javascript server-side feature?

            Code:
            <!DOCTYPE html>
            <html>
            <head>
            <meta name="generator" content="Alpha Anywhere HTML Editor Version 12 Build 2689-4440">
            <!-- must use in order to make XP Themes render -->
            <meta HTTP-EQUIV="MSThemeCompatible" content="Yes" />
            <meta http-equiv="X-UA-Compatible" content="IE=edge" />
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
            <meta name="apple-mobile-web-app-capable" content="yes" />
            
            <title>SQL from Javascript</title>
            </head>
            <body>
            <p>The code block on this page is server-side javascript</p>
            
            <a5%
            debugger;
            var country = request.variables.country;
            if(typeof country === 'undefined') country='uk';
            var a5 = AlphaAnywhere;
            var cn = new a5.sql.connection();
            var args = new a5.sql.arguments();
            args.add('whatCountry',country);
            var cs = '::Name::northwind';
            var flag = cn.open(cs);
            print('Connection was opened:'+flag+'<br><br>');
            var sql = "select * from customers where country = :whatCountry";
            flag = cn.execute(sql.args);
            if(flag === false) {
            	print('error executing sql');
            } else {
            	var rs = cn.resultset;
            	var flag = rs.nextRow();
            	var count = 0;
            	var arr = [];
            	debugger;
            	while(flag){
            		count = count + 1;
            		arr.push('<p>'+rs.data("customerId")+'</p>');
            		flag = rs.nextRow();
            	}
            	var html = arr.join('');
            	print(html);
            	print('<br><br>');
            	print('rows in query:'+count);
            }
            cn.close();
            %>
            
            </body>
            </html>
            Tiago - You're missing one critical element in your document for this to work:

            Code:
            <!--A5Language:Javascript-->
            I don't know if you noticed, but this line of code is the first line in Selwyn's original a5w page. You can see it in the video before he copies the <%a5 %> portion of the code to another application to make the font size larger (Skip to 11:16 in the video found here: http://www.alphasoftware.com/conf2014/).

            Also, you have a number of errors in your code.

            The start of the a5 block is <%a5, not <a5%:
            Code:
            <%a5
            You need a comma after sql, not a period:
            Code:
            flag = cn.execute(sql,args);
            There may be other issues --- I didn't test this but ran similar code against my DB and it works with the A5Language declaration.

            With these changes, your document becomes this (test it and work out any other errors you may have):
            Code:
            <!--A5Language:Javascript-->
            <html>
            <head>
            <meta name="generator" content="Alpha Anywhere HTML Editor Version 12 Build 2689-4440">
            <!-- must use in order to make XP Themes render -->
            <meta HTTP-EQUIV="MSThemeCompatible" content="Yes" />
            <meta http-equiv="X-UA-Compatible" content="IE=edge" />
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
            <meta name="apple-mobile-web-app-capable" content="yes" />
            
            <title>SQL from Javascript</title>
            </head>
            <body>
            <p>The code block on this page is server-side javascript</p>
            
            <%a5
            debugger;
            var country = request.variables.country;
            if(typeof country === 'undefined') country='uk';
            var a5 = AlphaAnywhere;
            var cn = new a5.sql.connection();
            var args = new a5.sql.arguments();
            args.add('whatCountry',country);
            var cs = '::Name::northwind';
            var flag = cn.open(cs);
            print('Connection was opened:'+flag+'<br><br>');
            var sql = "select * from customers where country = :whatCountry";
            flag = cn.execute(sql,args);
            if(flag === false) {
            	print('error executing sql');
            } else {
            	var rs = cn.resultset;
            	var flag = rs.nextRow();
            	var count = 0;
            	var arr = [];
            	debugger;
            	while(flag){
            		count = count + 1;
            		arr.push('<p>'+rs.data("customerId")+'</p>');
            		flag = rs.nextRow();
            	}
            	var html = arr.join('');
            	print(html);
            	print('<br><br>');
            	print('rows in query:'+count);
            }
            cn.close();
            %>
            
            </body>
            </html>
            Regarding Node.js, check out this video for information on calling Node.js from xbasic: http://www.alphasoftware.com/video-l...js&search=node

            The release notes include additional written information (search for node.js): http://downloads.alphasoftware.com/A...easenotes.html

            I hope this information is helpful.
            ---
            Sarah
            Last edited by TheSmitchell; 07-31-2015, 09:35 AM. Reason: adding updated "fixed" code example
            Alpha Anywhere latest pre-release

            Comment


              #7
              Re: Javascript server-side

              Overwhelming nice!

              Code:
              <!--A5Language:Javascript-->
              <%a5 
              
              var a = 1;
              var b = 2;
              var tday = new Date();
              print(a + b + '<br>');
              print(tday);
              %>

              Comment


                #8
                Re: Javascript server-side

                Not sure why my code is failing at

                var cn = new a5.sql.connection();

                is there a need to include a5.sql somewhere in the above code?

                [I am getting the "error executing sql" error from the code. My connection string is right and SQL table is valid in the database, I have another post with similar issue, but though that I may get quicker response from here.]

                Regards!

                Comment


                  #9
                  Re: Javascript server-side

                  Originally posted by Mkpatil View Post
                  Not sure why my code is failing at

                  var cn = new a5.sql.connection();

                  is there a need to include a5.sql somewhere in the above code?

                  [I am getting the "error executing sql" error from the code. My connection string is right and SQL table is valid in the database, I have another post with similar issue, but though that I may get quicker response from here.]

                  Regards!
                  Hi! Could you post all of your code or provide a link to the other post? The single line you provided is not nearly enough information to find the problem.
                  Alpha Anywhere latest pre-release

                  Comment


                    #10
                    Re: Javascript server-side

                    Does not work with server-side javascript using nodejs. But works server-side xbasic (doing this to confirm I have the right connection string and table names).
                    Error is "Connection was opened:false error executing sql"

                    Does not work:
                    <!--A5Language:Javascript-->
                    <html>
                    <head>
                    <meta name="generator" content="Alpha Anywhere HTML Editor Version 12 Build 2689-4440">
                    <!-- must use in order to make XP Themes render -->
                    <meta HTTP-EQUIV="MSThemeCompatible" content="Yes" />
                    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
                    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
                    <meta name="apple-mobile-web-app-capable" content="yes" />

                    <title>SQL from Javascript</title>
                    </head>
                    <body>
                    <p>The code block on this page is server-side javascript</p>

                    <%a5
                    debugger;
                    var a5 = AlphaAnywhere;
                    var cn = new a5.sql.connection();
                    var args = new a5.sql.arguments();
                    args.add('Userid','%@%');
                    var cs = '::Name::Connection1';
                    var flag = cn.open(cs);
                    print('Connection was opened:'+flag+'<br><br>');
                    var sql = "SELECT Userid FROM registeredusers where Userid = :Userid";
                    flag = cn.execute(sql,args);
                    if(flag === false) {
                    print('error executing sql');
                    } else {
                    var rs = cn.resultset;
                    var flag = rs.nextRow();
                    var count = 0;
                    var arr = [];
                    debugger;
                    while(flag){
                    count = count + 1;
                    arr.push('<p>'+rs.data("Userid")+'</p>');
                    flag = rs.nextRow();
                    }
                    var html = arr.join('');
                    print(html);
                    print('<br><br>');
                    print('rows in query:'+count);
                    }
                    cn.close();
                    %>

                    </body>
                    </html>
                    works with xbasic
                    <!--A5Language-->
                    <html>
                    <head>
                    <meta name="generator" content="Alpha Anywhere HTML Editor Version 12 Build 2689-4440">
                    <!-- must use in order to make XP Themes render -->
                    <meta HTTP-EQUIV="MSThemeCompatible" content="Yes" />
                    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
                    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
                    <meta name="apple-mobile-web-app-capable" content="yes" />

                    <title>xbasic</title>
                    </head>
                    <body>
                    <p>xBasic</p>

                    <%a5
                    dim cn as sql::connection
                    flag = cn.open("::Name::Connection1")
                    dim sqlCommand as c
                    sqlCommand = "SELECT Userid FROM registeredusers where Userid like :Userid";
                    dim args as sql::arguments
                    args.add("Userid","%@%");
                    flag = cn.execute(sqlCommand,args)
                    dim rs as sql::ResultSet
                    rs = cn.ResultSet

                    'This shows the first row in the Result Set
                    flag = rs.nextRow()

                    dim txt as c
                    while flag
                    txt = txt + "Userid: " + rs.data("Userid") + crlf()
                    flag = rs.nextRow()
                    end while
                    ?txt
                    %>

                    </body>
                    </html>
                    Regards!

                    Comment


                      #11
                      Re: Javascript server-side

                      Originally posted by Mkpatil View Post
                      Does not work with server-side javascript using nodejs. But works server-side xbasic (doing this to confirm I have the right connection string and table names).
                      Error is "Connection was opened:false error executing sql"

                      Does not work:


                      works with xbasic


                      Regards!

                      I copied your code verbatim. I changed the SQL statement because I don't have a table called "registeredusers" - but I have something else that's pretty similar. I also don't have a connection string called "Connection1", so my cs variable changed to "::Name::conn". With those two changes and nothing else, the code executed fine. Here's the result:
                      Code:
                      <!--A5Language:Javascript-->
                      <html>
                      <head>
                      <meta name="generator" content="Alpha Anywhere HTML Editor Version 12 Build 2689-4440">
                      <!-- must use in order to make XP Themes render -->
                      <meta HTTP-EQUIV="MSThemeCompatible" content="Yes" />
                      <meta http-equiv="X-UA-Compatible" content="IE=edge" />
                      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                      <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
                      <meta name="apple-mobile-web-app-capable" content="yes" />
                      
                      <title>SQL from Javascript</title>
                      </head>
                      <body>
                      <p>The code block on this page is server-side javascript</p>
                      
                      <%a5
                      debugger;
                      var a5 = AlphaAnywhere;
                      var cn = new a5.sql.connection();
                      var args = new a5.sql.arguments();
                      args.add('Userid','%@%');
                      var cs = '::Name::conn';
                      var flag = cn.open(cs);
                      print('Connection was opened:'+flag+'<br><br>');
                      var sql = "SELECT Userid FROM users where Userid = :Userid";
                      flag = cn.execute(sql,args);
                      if(flag === false) {
                      print('error executing sql');
                      } else {
                      var rs = cn.resultset;
                      var flag = rs.nextRow();
                      var count = 0;
                      var arr = [];
                      debugger;
                      while(flag){
                      count = count + 1;
                      arr.push('<p>'+rs.data("Userid")+'</p>');
                      flag = rs.nextRow();
                      }
                      var html = arr.join('');
                      print(html);
                      print('<br><br>');
                      print('rows in query:'+count);
                      }
                      cn.close();
                      %>
                      
                      </body>
                      </html>
                      Is your connection string published locally? I see that it worked in your xbasic example. Is it named "Connection1" exactly in the setup?
                      Alpha Anywhere latest pre-release

                      Comment


                        #12
                        Re: Javascript server-side

                        Thank you for your time.
                        Yes, in the test server it is Connection1 exactly and does not work for nodejs.
                        I use the same connection string for UX lists, radio button lists etc and the a5w file above (as you noticed) and it works fine.
                        This test server does not have development tool, just plain alpha WAS only.
                        I publish the project and all including the connection strings comes over to this test server. Do I need to do something more than publish?
                        "Is your connection string published locally" - please explain this.

                        Regards!

                        Comment


                          #13
                          Re: Javascript server-side

                          Thanks Sarah, I didn't see <!--A5Language:Javascript--> in the video.

                          This feature is a big step for Alpha, there is another world (nodejs) that can be integrated in Alpha.

                          Some another questions:

                          Can I use the interative code editor to explore: var a5 = AlphaAnywhere; ?

                          It is possible to use the converter tool (from the video), to convert from xbasic to javascript?

                          Thanks to everyone.

                          Comment


                            #14
                            Re: Javascript server-side

                            Originally posted by Mkpatil View Post
                            Thank you for your time.
                            Yes, in the test server it is Connection1 exactly and does not work for nodejs.
                            I use the same connection string for UX lists, radio button lists etc and the a5w file above (as you noticed) and it works fine.
                            This test server does not have development tool, just plain alpha WAS only.
                            I publish the project and all including the connection strings comes over to this test server. Do I need to do something more than publish?
                            "Is your connection string published locally" - please explain this.

                            Regards!
                            I think I just figured out what's going on...

                            I never published my file to a server. I published locally, which always worked.

                            When tested remotely, I saw the same problem. You can print out the error from the in the sql::connection object using the same method as in xbasic:

                            Code:
                            print(cn.callresult.text);
                            I am seeing this error:
                            Error 1000 - The filename, directory name, or volume label syntax is incorrect. " /test_serversidejs.a5w" Error converting named connection to connection string
                            This may be a bug in the system. I would encourage you to send in a bug report.
                            Attached Files
                            Alpha Anywhere latest pre-release

                            Comment


                              #15
                              Re: Javascript server-side

                              I have confirmed my assumptions.

                              There is an issue in the application server. It's not replacing the named connection string properly on the server for some reason.

                              You can replace "::Name::Connection1" with the literal connection string - password unencrypted. Alpha will successfully open the connection.

                              EG:
                              Code:
                              var cs = "{A5API=MySQL,Server='localhost',Port='9999',UserName='user1',Password='password',Database='my_db'}";
                              Alpha Anywhere latest pre-release

                              Comment

                              Working...
                              X