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

Get a "message box" from XBasic

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

  • Get a "message box" from XBasic

    Previously, I've been able to use "Alert" in my XBasic code to get a simple Message Box Alert for the user, but for my current UX, it's not working. I hope someone could see what I've typed incorrectly. The name of the XBasic function is
    "CheckPO" and is defined like this:
    function CheckPO as c (e as p)

    I've added this command, after the code has been run:
    CheckPO = "alert('Your Tax Tables Were Successfully Fixed! \n You can close this form!');"

    I've used that EXACT command in other applications and the message box comes up, but not on this form. I've stepped through the function, with the debugger and it passes that command without any errors, but nothing pops up in Working Preview or Live Preview.

    Perhaps, I should be using a "msgbox" command or something else.

    I'd appreciate it if anyone can figure out what I'm doing wrong.


  • #2
    Are you calling this Xbasic function as part of an AJAX callback? If not, it will not return the javascript. I know that may sound like a stupid question, but if you will humor me, put a button on your UX, set it up as an AJAX callback, and call the function.
    What does that do?

    Jay
    Jay Talbott
    Lexington, KY

    Comment


    • #3
      Hi Jay-

      THANK YOU so much for responding. It was very kind of you to help me.

      YES, my command is an Ajax Callback from a button on the UX (see image below): Ajax1.jpg

      Here's the code for the Function Called "CheckPO": Ajax3.jpg


      The part that's messing me up is that in "debug" mode, it goes through the code perfectly and processes the "Alert" command (see below), but the alert doesn't display... it just finishes stepping though the function without doing anything. I tried in "Working Preview", "Live Preview" and I even uploaded the component to the "live" program, to see if it would display the alert... no success. Ajax4.jpg


      Is there an XBasic "msgbox" function I can use that does the same thing? Is there an easy way for XBasic to pop up an Alpha component, in a "Window", that might accomplish what I want? I expected this to be easy, so I'm just looking for any alternate way to get to the same place.

      I'd appreciate any thoughts.

      Comment


      • #4
        Try this instead:

        function CheckPO as c ( e as p)
        DIM cn AS sql::Connection
        DIM sqlCommand AS c = ""
        DIM rs AS sql::ResultSet
        DIM flag1 AS L = .F. DIM flag2 AS L = .F.
        flag1 = cn.Open("::name::Grelak-Sql")
        sqlCommand = "SELECT COUNT(*) FROM CheckPONum"
        flag2 = cn.Execute(sqlCommand)
        rs = cn.ResultSet debug(1)
        IF rs.data(1) > 0 THEN
        CheckPO = "alert('Your Tax Tables...!');"
        END IF

        end function
        (change the sqlCommand, as I was too lazy to type out the entire command)

        Use COUNT(*) instead of SELECT *

        RS.CurrentRowIndex defaults to 0 so your IF statement was not completing.

        I don't like the RS.CurrentRowIndex, although if you insist on using something like that, you can use :

        IF rs.NextRow()
        CheckPO = "alert(......

        END IF

        Also, I removed the "return sqlCommand"

        And I like to put the javascript which the function returns as the last line, so you could change the script to this:
        function CheckPO as c ( e as p)
        DIM cn AS sql::Connection
        DIM sqlCommand AS c = ""
        DIM rs AS sql::ResultSet
        DIM flag1 AS L = .F. DIM flag2 AS L = .F.
        DIM js AS c = ""

        flag1 = cn.Open("::name::Grelak-Sql")
        sqlCommand = "SELECT COUNT(*) FROM CheckPONum"
        flag2 = cn.Execute(sqlCommand)
        rs = cn.ResultSet debug(1)
        IF rs.data(1) > 0 THEN
        js = "alert('Your Tax Tables...!');"
        END IF
        CheckPO = js

        end function

        Good luck.
        Jay
        Jay Talbott
        Lexington, KY

        Comment


        • #5
          ...and if you would like to display a nice messagebox instead of the alert, then use A5.msgbox, i.e in Jay's code for instance, replace

          Code:
          js = "alert('Your Tax Tables....!);"
          with

          Code:
          js = <<%str%
          var title = 'Important Message';
          var html = '<p>Your Tax Tables were successfully fixed!</p>';
          var type = 'o';
          A5.msgBox.show(title, html, type);
          %str%
          You can even use the messagebox to get action from the user, see it in the documentation: https://documentation.alphasoftware....w%20Method.xml

          Jaime

          Comment


          • #6
            Thanks, Jamie. You are correct, that would be a much nicer message box. Now to make sure that it fires....
            Jay Talbott
            Lexington, KY

            Comment


            • #7
              Hi Jay and Jaime... First of all, you are both amazing! Both of your suggestions worked great (the Javascript msgbox flred perfectly... and I love how it looks. I thought SQL was one of my specialties, but I never used the "SELECT COUNT (*) command... it worked great (I had to add a where clause, but it was no problem)

              There's one more small step where I could use some help: When asking for assistance, I didn't want to over-complicate the issue, so I didn't include everything I'm trying to do with the alert. In short, I want the alert to do an Ajax Callback to check for "duplicate P.O. #'s" and pop-up a message box (thanks to your code enhancements, it works perfectly with the XBasic pop-up or Jaime's Javascript message box). However, I had wanted to tell the user, in the message box, where to find the duplicate. Right now, the system works great to tell the user there's a duplicate ("That P.O. was previously used for Call #:" That pop-up works perfectly, now), but I want to add the job # where the P.O. was previously used ("That P.O. was previously used for Call #:45687" That's the part I can't get to work),

              Once you helped me with the message box/alert, I expected it to be simple to add a "field" to the message itself. So I created a field in the XBasic code called "CheckCallNum", which I got from the recordset data (I did a second SQL Command to get the Call Number of the record... you'll see it in the code below). "rs2" gets the Call Number perfectly and I converted it to a "string" so that it could be added to the "alert" command. It works great.

              However, when I add + CheckCallNum to the alert, nothing fires... I don't get any alert. When I remove + CheckCallNum, it fires perfectly (You'll see what I tried in the code, below... it's commented out).

              Maybe there's no way to a the data variable to an alert, but I was positive, I had done it previously, with another application. If it's not possible, that's OK, I'll live with the alert, without the Call Number. If it IS possible (with the Alert or the Javascript Message Box), I'd appreciate it, if you can tell me what I'm doing wrong.

              Either way, I really appreciate the time both of you have given to this issue. The Alpha community is so generous to offer help.

              With appreciation,
              Phil
              function CheckPO as c (e as p)
              DIM cn AS sql::Connection
              Dim args as sql::Arguments
              DIM rs AS sql::ResultSet
              DIM rs2 AS sql::ResultSet
              ' Newly Added
              DIM sqlCommand AS c = ""
              DIM sqlCommand2 AS c = ""
              ' Newly Added
              Dim PONum1 as c = ""
              Dim Custnum1 as n
              Dim CheckCallNum as c = ""
              ' Newly Added
              DIM flag1 AS L = .F.
              DIM flag2 AS L = .F.
              DIM flag3 AS L = .F.
              ' Newly Added
              Dim js AS c = ""

              ‘I’ll need the following ONLY if a duplicate is found (very rare... they don't have many duplicates, but I need this program to make sure it never happens)
              CustNum1 = e._CurrentRowDataNew.CustNum2
              PONum1 = e._CurrentRowDataNew.CustomerPO

              args.set("CustNum",CustNum1)
              args.set("PONum",PONum1)

              flag1 = cn.Open("::name::Grelak-SQL")
              sqlCommand = "SELECT COUNT(*) FROM CheckPONum WHERE CustNum=:CustNum And CustomerPONum =:PONum"
              SqlCommand2 = "SELECT * FROM CheckPONum WHERE CustNum = :CustNum AND CustomerPONum = :PONum;"
              flag2 = cn.Execute(sqlCommand,args)
              rs = cn.ResultSet

              IF rs.data(1) > 0 THEN
              'Since there's data, it means the PO was previously used and has been duplicated;
              ' so I want to tell the user where to look for the duplicate.
              ' It's easy to find, because the original Call # where the P.O. was used can be easily found, here:
              flag3 = cn.Execute(sqlCommand2,args)
              rs2 = cn.ResultSet
              CheckCallNum = str(rs2.Data("CallNum"))
              ' FYI the CheckCallNum string displays perfectly when I checked with Debug(1)

              js= "alert('That P.O. was previously used for Call #: ');"
              'Works Perfectly!

              ' js= "alert('That P.O. was previously used for Call #: ' + CheckCallNum);"
              ' But I get No Alert at all when I add the "CheckCallNum" string variable

              'js = <<%str%
              'var title = 'Important Message';
              'var html = '<p>That P.O. was previously used for Call #: </p>';
              'var type = 'o';
              'A5.msgBox.show(title, html, type);
              '%str%
              END IF
              CHECKPO = js
              end function

              Comment


              • #8
                If you are sure you are getting the correct value for CheckCallNum, the only issue is your js.
                It should read:

                js= "alert('That P.O. was previously used for Call #: ' " + ALLTRIM(STR(CheckCallNum)) + ");"
                I think your syntax was just a bit messed up. The above should fix it.

                Jay
                Jay Talbott
                Lexington, KY

                Comment


                • #9
                  Hi Jay-

                  Well, clearly my syntax was messed up... However, when I substituted your command, the Alert didn't fire at all. So, I checked with Debug(1) and it looks exactly the way I wanted it to look (you're amazing)... but the box didn't pop up (see Debug info below). When I went back to the original code, the Alert DID fire (without the Call #, of course). Maybe I there's something that's still wrong (I used copy/paste to insert your code), that caused the Alert not to pop up.

                  Let me know what you think... and thanks so much for your patience and persistence.

                  Phil
                  Ajax5.jpg

                  Comment


                  • #10
                    I believe that I had a mistake in my js. It should probably read:
                    js= "alert('That P.O. was previously used for Call #: " + ALLTRIM(STR(CheckCallNum)) + " ' );" //moving the single closing apostrophe after the CheckCallNum

                    Try that. I checked the corrected js in the Chrome debugger console and I think it should work now.
                    Jay Talbott
                    Lexington, KY

                    Comment


                    • #11
                      Hi Jay-

                      That's Perfect! Glad you saw what was wrong, because I could have stared at it forever and not known what to do. If a duplicate P.O. is detected, for that customer, this alert pops up: Ajax6.jpg


                      That's exactly what I wanted, so I can't thank you enough.

                      Below, I've posted the final full code for the Ajax Callback function, so that it might help someone else who's trying to accomplish something similar. There's a lot going on, here, so I hope someone else can use it.

                      Thanks again for getting me though this.

                      With appreciation,
                      Phil

                      function CheckPO as c (e as p)
                      DIM cn AS sql::Connection
                      Dim args as sql::Arguments
                      DIM rs AS sql::ResultSet
                      DIM rs2 AS sql::ResultSet
                      DIM sqlCommand AS c = ""
                      DIM sqlCommand2 AS c = ""
                      Dim PONum1 as c = ""
                      Dim Custnum1 as n
                      Dim CheckCallNum as c = ""
                      DIM flag1 AS L = .F.
                      DIM flag2 AS L = .F.
                      DIM flag3 AS L = .F.
                      Dim js AS c = ""
                      CustNum1 = e._CurrentRowDataNew.CustNum2
                      PONum1 = e._CurrentRowDataNew.CustomerPO

                      args.set("CustNum",CustNum1)
                      args.set("PONum",PONum1)

                      flag1 = cn.Open("::name::Grelak-SQL")
                      sqlCommand = "SELECT COUNT(*) FROM CheckPONum WHERE CustNum=:CustNum And CustomerPONum =:PONum"
                      SqlCommand2 = "SELECT * FROM CheckPONum WHERE CustNum = :CustNum AND CustomerPONum = :PONum;"

                      flag2 = cn.Execute(sqlCommand,args)
                      rs = cn.ResultSet
                      IF rs.data(1) > 0 THEN
                      'Since there's data, it means the PO was previously used;
                      'The next command gets the specific record.
                      flag3 = cn.Execute(sqlCommand2,args)
                      rs2 = cn.ResultSet
                      CheckCallNum = str(rs2.Data("CallNum"))

                      js= "alert('That P.O. was previously used for Call #: " + AllTrim(CheckCallNum) + "');"
                      END IF

                      CHECKPO = js

                      end function

                      Comment


                      • #12
                        Great to hear, Phil. Thanks for posting the final script, as this may help someone in the future.
                        All the best with your development work,
                        Jay
                        Jay Talbott
                        Lexington, KY

                        Comment

                        Working...
                        X