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

How To Code MsgBox

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

    How To Code MsgBox

    I am JUST BARELY getting started with A5 web development. I am unable to display a simple msgbox for code checking:

    function CanUpdateRecord as v (DataSubmitted as P, Args as p, PageVariables as p, Result as p )
    option strict
    dim gochoice as c
    gochoice = DataSubmitted.STATUS
    debug(1)
    select
    case "Complete"
    ui_msg_box("test", gochoice,1) 'PRODUCES ERROR MSG "a5wui not found"

    end select
    with PageVariables
    Result.Cancel = .f.
    Result.ErrorHTML = ""
    end with
    end function

    WHAT SHOULD I DO DIFFERENTLY?

    Thanks!!

    #2
    Re: How To Code MsgBox

    Does this help?

    http://msgboard.alphasoftware.com/al...ad.php?t=86340

    Comment


      #3
      Re: How To Code MsgBox

      christappan:

      Thanks for coming back to me on this. I am learning that for all the hoopla about how easy Alpha Five is, there is a serious and largely undocumented learning curve. The link you gave me mentions that the genie-created xbasic code is "an example of the genie code generated which will not run in a web application." This is news to me, and bad news at that. Now I have to try to find documentation on what Xbasic functions will or will not run in a web application. Any idea where such documentation might be located?

      Thanks again.

      Comment


        #4
        Re: How To Code MsgBox

        I'm pretty new at this, self-taught, and used only the web side of things, so don't read this as coming from an expert. The Alpha help file is pretty reliable with its "limitations" at the bottom of each function description, letting you know what's web-only or desktop only. Most things that I did via the genie, the message box is the thing that you'll need to remove consistently before trying to use.

        You'll see on the forum both the frustrations of users like us who don't realize that the web side of Alpha was built long after the desktop and similarly the frustration of desktop application builders who feel like all the improvements are for the web side.

        You'll also see almost everyone entering Alpha development express frustrations at the lacking and inconsistent help documentation, which supposedly Martin Heller has been hired specifically to address, but that will obviously take some time.

        The genies are good; when they don't work, I tend to search the forum and then the Alpha help file.

        Comment


          #5
          Re: How To Code MsgBox

          Thanks, Chris. I'll keep on keeping on and check the Alpha help file.

          Comment


            #6
            Re: How To Code MsgBox

            Originally posted by clayrankin View Post
            WHAT SHOULD I DO DIFFERENTLY?
            UI methods won't run on the web. The Browser controls the web interface through HTML & JavaScript, etc. You can put a message box up using Action JavaScript. Go to properties/JavaScript System events.
            Peter
            AlphaBase Solutions, LLC

            [email protected]
            https://www.alphabasesolutions.com


            Comment


              #7
              Re: How To Code MsgBox

              So, if you are using the Code Editor to write an Xbasic function for an Ajax Callback that will delete a record based on certain criteria, how do you put a message box in the code that will pop up to confirm the deletion before it happens?

              I have, with Selwyn's help, accomplished writing the code to lookup in a child table to see if the value in the parent table has been used in the child table, and then, if not, it automatically deletes the record. The code is called with an Ajax Callback from the OnClick event of a button.

              I don't want the delete to happen without a confirmation from the user, and have searched all day to try to figure out how to create code for a pop up message box to with OK or Cancel.

              I absolutely think there needs to be a separation of Help for desktop and web application development. Because, of course, I launched off and tried to use the ui_msg_box which turns out will not work in a web app.
              Carol King
              Developer of Custom Homebuilders' Solutions (CHS)
              http://www.CHSBuilderSoftware.com

              Comment


                #8
                Re: How To Code MsgBox

                So, now I'm messing around with confirm() which I found by going to the text mode for a Message Box created with Action Javascript. My XBasic function name is LookupInChildTablesThenDeleteIfNotFound. The code between the If and End If does work because it's used elsewhere in If statements in the function and is fine, so the error is from the msgResult stuff.

                dim msgResult as ? (I've tried both L and 1, AND I've also tried it without the dim statement)

                msgResult = confirm('Confirm Delete?')

                if msgResult = .f. then
                'user did not click ok to confirm the delete
                cn.Close()
                dim msg as c
                msg = "The record has not been deleted per your request."
                msg = js_escape(msg)
                dim jscmd as c
                jscmd = "alert('" + msg + "');"
                LookupInChildTablesThenDeleteIfNotFound = jscmd
                exit function
                end if
                Carol King
                Developer of Custom Homebuilders' Solutions (CHS)
                http://www.CHSBuilderSoftware.com

                Comment


                  #9
                  Re: How To Code MsgBox

                  You have got to use HTML or JavaScript to communicate with the client in a web app.

                  So if a callback needs to display a JavaScript confirm box, then return that JavaScript from the callback and if the user chooses to delete the record, you'll need to do another callback to delete it. It is a two step process in your unique case.
                  Bob Moore


                  Comment


                    #10
                    Re: How To Code MsgBox

                    Originally posted by clayrankin View Post
                    I am JUST BARELY getting started with A5 web development. I am unable to display a simple msgbox for code checking:

                    function CanUpdateRecord as v (DataSubmitted as P, Args as p, PageVariables as p, Result as p )
                    option strict
                    dim gochoice as c
                    gochoice = DataSubmitted.STATUS
                    debug(1)
                    select
                    case "Complete"
                    ui_msg_box("test", gochoice,1) 'PRODUCES ERROR MSG "a5wui not found"

                    end select
                    with PageVariables
                    Result.Cancel = .f.
                    Result.ErrorHTML = ""
                    end with
                    end function

                    WHAT SHOULD I DO DIFFERENTLY?

                    Thanks!!
                    this code you have written here shows that you don't seem to appreciate the difference between server side events (written in xbasic) and client side events (written in javascript).

                    the canUpdateRecord() event is a server side event.
                    that means that it fires on the Application server.
                    so, if ui xbasic functions were not disabled in a web app, when this code executed and hit the ui_msg_box() function, it would pop up a modal message box on the server.

                    of course, since the message box would be on the server, it would not be visible to any user because a user can't see what's happening on the server. all that the user can see is the html that the server sends to their browser over the internect.

                    and even worse, the ui_msg_box() is modal - so the server would stop responding to other requests until someone dismissed the modal message box - which of course would never happen because no one can see it.

                    so, if a server side event wants to display some ui to the user, then the server side event needs to send back the appropriate javascript commands that display the message to the browser.

                    Comment


                      #11
                      Re: How To Code MsgBox

                      Step by Step trial and error:

                      1 - Selwyn provided me with this code that does cause a Javascript message box to pop up on the client side. The name of my function is LookupInChildTablesThenDeleteIfNotFound. Per Selwyn, "In xbasic the way a function returns a value is you set the function name to the value you want to return."

                      cn.Close()
                      dim msg as c
                      msg = "The record has not been deleted per your request."
                      msg = js_escape(msg)
                      dim jscmd as c
                      jscmd = "alert('" + msg + "');"
                      LookupInChildTablesThenDeleteIfNotFound = jscmd
                      exit function

                      2 - Since calling that Javascript Alert box apparently does return a value, I went to W3 Schools and found info on the Javascript confirm box. "'A confirm box is often used if you want the user to verify or accept something. When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed. If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false. Syntax: confirm("sometext");" http://www.w3schools.com/js/js_popup.asp

                      3 - So, I tried to mimic the code Selwyn sent me for the alert box to cause a confirm box to pop up:

                      dim confirmMsg as c
                      confirmMsg = "Press OK to confirm the delete."
                      confirmMsg = js_escape(confirmMsg)
                      dim jsresult as c 'don't know what to dim as
                      jsresult = "confirm('" + confirmMsg + "');"

                      When I run it, absolutely nothing happens. Do you know why, Selwyn? Does it need to have the cn.close first in order to close the connection before we can come back to the client side for the confirm pop up? Or, have you written something to specifically handle the alert box but not the confirm box when Alpha converts Xbasic to Javascript? OR, did I just write it wrong?

                      4 - If I can succeed in getting the confirm box to pop up, how will I refer to the result value that it returns? As "true" or "false", or as .t. or .f. ? And what type do I dim the variable to for holding the result?

                      If jsresult = "false" then
                      OR
                      If jsresult = .f. then

                      5 - If I succeed in identifying the jsresult value to use in an If statement, do I have to call another function to do the deletion if it's true (user clicked ok)? How do I do that? OR, can I even use the If statement to do something with the result? If not, can I pass the result of the confirm box to another called function? And, how do you do that? (I know it must be the arguments passed to the function, but an example would sure be nice.) BTW, I can't use 2 actions on the same delete button with Ajax callbacks, because according to Selwyn, the ajax callbacks will be asynchronous and fire at the same time. So, when Bob Moore suggests that it is a "two step process" to do first one callback, then another, I, in my newness, get all lost as to how to do that in alpha. I'm used to using "call" in VB to call other functions, but is it the same in Xbasic for a web component? And, again, if so, how do I get the result from the confirm box?
                      Last edited by kingcarol; 08-09-2010, 10:31 AM.
                      Carol King
                      Developer of Custom Homebuilders' Solutions (CHS)
                      http://www.CHSBuilderSoftware.com

                      Comment


                        #12
                        Re: How To Code MsgBox

                        This code will work:
                        Code:
                        confirmMsg = "Press OK to confirm the delete."
                        confirmMsg = js_escape(confirmMsg)
                        JSconfirmBox = "confirm('" + confirmMsg + "');"
                        end function
                        Here is how to process a confirm box:
                        Code:
                        r=confirm("Press a button");
                        if (r==true)
                          {
                         alert('You pressed OK!');
                          }
                        else
                          {
                          alert('You pressed Cancel!');
                          }
                        However, you won't be able to do this in an xbasic callback since the function has to return the JS. Once it does that you are out of the loop and can't process the results. You need to think of a different approach. e.g. use your button to popup a dialog that asks if you want to delete xyz. Note: this is not Alpha's fault, but the web's limitations - the old disconnected model.

                        Or, have you written something to specifically handle the alert box but not the confirm box when Alpha converts Xbasic to Javascript?

                        Alpha doesn't convert xbasic to JS. It sends any xbasic (in an AJAX xbasic callback function) to the server (to the WAS), which does understand xbasic and processes it there. But the callback function allows you to return JS to the browser (if you wish) and do something there.

                        I can't use 2 actions on the same delete button with Ajax callbacks, because according to Selwyn, the ajax callbacks will be asynchronous and fire at the same time.

                        Exactly. However, Bob may have something clever up his sleeve. If so, perhaps he will inform us.

                        The bottom line is that the web is a different animal than the desktop, and you can't do things the same way in a browser as you can in a desktop program. You have to approach things differently.
                        Peter
                        AlphaBase Solutions, LLC

                        [email protected]
                        https://www.alphabasesolutions.com


                        Comment


                          #13
                          Re: How To Code MsgBox

                          OK, popping up a message box to confirm the delete BEFORE launching into the ajax callback makes sense. I got all caught up in the fact that the callback was validating some things before doing the delete, so was trying to put the confirm after the validation... uh, who knows why....

                          So, looks like a message box will give me some sort of true/false result. How do I use that to launch the Ajax callback?

                          I've tried Help to find Message Box with no luck, so guess I'll try to search threads. Would be much appreciated, though, if someone puts the answer here.

                          And, believe me, I now know that programming desktop apps is way easier than web apps and that there are huge differences. And I'm definitely beginning to 'appreciate', as Selwyn puts it, the difference between client and server.
                          Carol King
                          Developer of Custom Homebuilders' Solutions (CHS)
                          http://www.CHSBuilderSoftware.com

                          Comment


                            #14
                            Re: How To Code MsgBox

                            Originally posted by kingcarol View Post
                            So, looks like a message box will give me some sort of true/false result. How do I use that to launch the Ajax callback?
                            Again, I don't think you can do that in the context of a button on a grid. You have to figure out an alternative methodology. That's why I suggested popping up a confirmatory dialog. The users presses your "Delete" button which would pop up a dialog (with the real delete button on it and a cancel button) on an a5w page. The dialog could say something like "Press Delete to delete this record or press Cancel to exit". - - - OR, you could also add a checkbox field to your row called "delete". The actual delete button would be hidden until they click the checkbox, then the delete button could just delete when pressed. You have to think differently about your approach.
                            Peter
                            AlphaBase Solutions, LLC

                            [email protected]
                            https://www.alphabasesolutions.com


                            Comment


                              #15
                              Re: How To Code MsgBox

                              OK, I'll go at it some other way. Now I'm curious, though....

                              Putting what I'm doing aside, what exactly is the OK/Cancel message box that you can create with Action Javascript good for? (see screenshot) What can you do with the True result that would be stored in the MsgResult variable if user clicks OK?

                              And, speaking generally....
                              If a function can get the result of a javascript alert box, which Selwyn DID DO, wouldn't it be possible to get the result of a javascript confirm box also? Then couldn't you use the true or false result of that function to send in as an argument to another function that you call?
                              Carol King
                              Developer of Custom Homebuilders' Solutions (CHS)
                              http://www.CHSBuilderSoftware.com

                              Comment

                              Working...
                              X