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

Trouble event trapping xdialog field values

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

    Trouble event trapping xdialog field values

    In the following xdialog code, I have an event placed on the priority field to report in a msgbox() the values in the text fields for Section, Pol_name, and Pol_no. and generate the field values for the last two fields by concatenating these field values. I believe it should be working, but it is not. It works in the small second example at the bottom. I'm not seeing where the problem lies. What am I missing? I've been at this for hours!! :( Thanks.

    Code:
    	dim global vproceed as c
    	dim vPrefix as C="LAB"
    	dim vSectn as C=""
    	dim vLsect as C
    		vLsect=comma_to_crlf("ADM,BLB,CYT,CHE,GEN,HEM,HIS,IMM,LIS,MIC,OFR,OPA,POC,QUA,SEN")
    	dim vGrouping as C
    	dim vPol_no as C
    	dim vini_date as D=date()
    	dim vrenew_date as D=date()+(365*5)
    	dim vPol_name as C="Policy Test"
    	dim vDc_number as C
    	dim vPol_num_full as C
    	dim vPriority as C
    	dim vsign_level as C
    	dim vSL as C="Supervisor"+crlf()+"Director"
    	dim dlg_text as C
    	
    	dlg_text = <<%dlg%
    	{background=#175,165,135}
    	{xmargin=2,2}
    	{frame=1,1}
    	{region}
    	Prefix: | [.10vprefix];
    	Section: | [.10vsectn^+vLsect];
    	Grouping: | [.10vgrouping]  900 ;
    	Policy Number: | [.10vpol_no]  905;
    	Initiate Date: | [%P=popup.calendar(dtoc(vini_date));I=popup.calendar%.16vini_date];
    	Renew_Date: | [%P=popup.calendar(dtoc(vrenew_date));I=popup.calendar%.16vrenew_date];
    	Policy Name: | [.30vpol_name];
    	Signature Level: | [.20vsign_level^+vSL];
    	Priority: | [.10vpriority!dcnx_*]  1-5  ;
    	Full Policy Number: | [.40vpol_num_full];
    	Doc Control No.: | [.40vdc_number];
    
    	{endregion};
    	{lf};
    	{line=1,0}
    	{lf};
    	{justify=center}<10OK> <10Cancel>
    	%dlg%
    	
    	dim vresults as C 
    	RETRY:
    	vresult=ui_dlg_box("Policy Entry", dlg_text, <<%code%
    	IF left( a_dlg_button, 5 ) = "dcnx_"
    	 IF a_dlg_button = "dcnx_change"
    	 	
    	 	vPol_num_full=vprefix+"_"+alltrim(vsectn)+"_"+alltrim(vPol_no)
    		vDc_number=vPol_num_full+"_"+cdate(vini_date)+"_"+cdate(vRenew_date)
    	 	
    	 	msgbox("Pol Name",vpol_name)
    	 	msgbox("Values","section:  "+alltrim(vsectn)+crlf()+"PN:  "+vpol_no)
    	 	
    	 END IF
    	 a_dlg_button = ""
    	END IF
    	%code%)
    
    		'vPol_num_full=vprefix+"_"+alltrim(vsectn)+"_"+alltrim(vPol_no)
    		'vDc_number=vPol_num_full+"_"+cdate(vini_date)+"_"+cdate(vRenew_date)
    		msgbox("Outcome",alltrim(vpol_num_full)+crlf()+alltrim(vdc_number))
    Code:
    	dim vR as C
    	dim vX as C=""
    	dim vY as C=""
    	dim vZ as C="Lab"
    	vR=ui_dlg_box("Date",<<%a%
    	[.30vZ];
    	[.30vX!dcnx_*];
    	[.30vY];
    	<ok>
    	%a%,<<%code%
    		IF left( a_dlg_button, 5 ) = "dcnx_"
    		 IF a_dlg_button = "dcnx_change"
    		 	
    		 		vY=vZ+"_"+vX
    		 
    		 END IF
    		 a_dlg_button = ""
    		END IF
    		%code%)
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

    #2
    Re: Trouble event trapping xdialog field values

    I got it. There is probably a less verbose way but it works. I placed event trapping on each field and it builds the concatented field values that I wanted as each field value is entered.

    Code:
    	dim vPrefix as C="LAB"
    	dim vSectn as C=""
    	dim vLsect as C
    		vLsect=comma_to_crlf("ADM,BLB,CYT,CHE,GEN,HEM,HIS,IMM,LIS,MIC,OFR,OPA,POC,QUA,SEN")
    	dim vPol_no as C
    	dim vGrouping as C
    	dim vini_date as D=date()
    	dim vrenew_date as D=date()+(365*5)
    	dim vPol_name as C="Policy Test"
    	dim vDc_number as C
    	dim vPol_num_full as C
    	dim vPriority as C
    	dim vsign_level as C
    	dim vSL as C="Supervisor"+crlf()+"Director"
    	dim dlg_text as C
    	
    	dlg_text = <<%dlg%
    	{background=#175,165,135}
    	{xmargin=2,2}
    	{frame=1,1}
    	{region}
    	Prefix: | [.10vprefix];
    	Section: | [.10vsectn^+vLsect!xfl1_*];
    	Grouping: | [.10vgrouping]  900 ;
    	Policy Number: | [.10vpol_no!xfl2_*]  905;
    	Initiate Date: | [%P=popup.calendar(dtoc(vini_date));I=popup.calendar%.16vini_date!xfl3_*];
    	Renew_Date: | [%P=popup.calendar(dtoc(vrenew_date));I=popup.calendar%.16vrenew_date!xfl4_*];
    	Policy Name: | [.30vpol_name];
    	Signature Level: | [.20vsign_level^+vSL];
    	Priority: | [.10vpriority!xfl5_*]  1-5  ;
    	Full Policy Number: | [.40vpol_num_full];
    	Doc Control No.: | [.40vdc_number];
    
    	{endregion};
    	{lf};
    	{line=1,0}
    	{lf};
    	{justify=center}<10OK> <10Cancel>
    	%dlg%
    	
    	dim vresult as C 
    	RETRY:
    	vresult=ui_dlg_box("Policy Entry", dlg_text, <<%code%
    	IF left( a_dlg_button, 5 ) = "xfl1_"
    	 IF a_dlg_button = "xfl1_change"
    	 	vPol_num_full=vprefix+"_"+alltrim(vsectn)+"_"+alltrim(vPol_no)
    		vDc_number=vPol_num_full+"_"+cdate(vini_date)+"_"+cdate(vRenew_date)
    	 END IF
    	 a_dlg_button = ""
    	END IF
    	
    	IF left( a_dlg_button, 5 ) = "xfl2_"
    	 IF a_dlg_button = "xfl2_change"
    	 	vPol_num_full=vprefix+"_"+alltrim(vsectn)+"_"+alltrim(vPol_no)
    		vDc_number=vPol_num_full+"_"+cdate(vini_date)+"_"+cdate(vRenew_date)
    	 END IF
    	 a_dlg_button = ""
    	END IF
    	
    	IF left( a_dlg_button, 5 ) = "xfl3_"
    	 IF a_dlg_button = "xfl3_change"
    	 	vPol_num_full=vprefix+"_"+alltrim(vsectn)+"_"+alltrim(vPol_no)
    		vDc_number=vPol_num_full+"_"+cdate(vini_date)+"_"+cdate(vRenew_date)
    	 END IF
    	 a_dlg_button = ""
    	END IF
    	
    	IF left( a_dlg_button, 5 ) = "xfl4_"
    	 IF a_dlg_button = "xfl4_change"
    	 	vPol_num_full=vprefix+"_"+alltrim(vsectn)+"_"+alltrim(vPol_no)
    		vDc_number=vPol_num_full+"_"+cdate(vini_date)+"_"+cdate(vRenew_date)
    	 END IF
    	 a_dlg_button = ""
    	END IF
    	
    	IF left( a_dlg_button, 5 ) = "xfl5_"
    	 IF a_dlg_button = "xfl5_change"
    	 	vPol_num_full=vprefix+"_"+alltrim(vsectn)+"_"+alltrim(vPol_no)
    		vDc_number=vPol_num_full+"_"+cdate(vini_date)+"_"+cdate(vRenew_date)
    	 END IF
    	 a_dlg_button = ""
    	END IF
    	%code%)
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

    Comment


      #3
      Re: Trouble event trapping xdialog field values

      If you want less verbose, take out all the :
      if left(a_dlg_button,5)=...
      end if

      I am pretty sure this came from the help file and it serves no purpose other than waste cyber space, keyboard strokes and your time.

      Comment


        #4
        Re: Trouble event trapping xdialog field values

        Mike, G has got the right idea (though I'd implement it a tiny bit differently) because you are trapping only the change event inside each IF ... END IF code block. If you were trapping other events for individual text boxes as well as the change event then the outer IF ... END IF code blocks are necessary. The text in red can be deleted because you're only trapping a single event for each text box. Does this make sense?

        Code:
        IF [COLOR="Red"]left( a_dlg_button, 5 ) = "xfl5_"
           IF[/COLOR] a_dlg_button = "xfl5_change"
              vPol_num_full=vprefix+"_"+alltrim(vsectn)+"_"+alltrim(vPol_no)
              vDc_number=vPol_num_full+"_"+cdate(vini_date)+"_"+cdate(vRenew_date)
           [COLOR="red"]END IF[/COLOR]
            a_dlg_button = ""
        END IF

        Comment


          #5
          Re: Trouble event trapping xdialog field values

          Actually Tom, it's a waste any way you look at it whether trapping one button or a dozen, trapping one event or a dozen. I don't know why it is in the help file.

          Comment


            #6
            Re: Trouble event trapping xdialog field values

            Hi Mike,

            Originally posted by Mike Wilson View Post
            I There is probably a less verbose way but it works. I placed event trapping on each field and it builds the concatented field values that I wanted as each field value is entered.
            Since all you need is a field's change event (which is the default),
            there is no need to specify event names ending in *, requiring the check for the event type. Just a simple event name will do

            Since all events are doing the identical thing, you can just use the same event name for all, I renamed all of the events to "combine". Consolidation of code, except for speed, is always better. By consolidating the code, it makes for cleaner, easier to read, easier to understand and easier to maintain code.

            Also, there is no event on the vprefix field, but you use it in the combined fields. Similarly, there is an event on the vpriority field, but it isn't used, so it's event is not necessary

            You may want to make vPol_num_full and vDc_number fields read only, as they are being recalculated whenever you change the other fields, which I did with a control directive %r% in the code below;

            Code:
            dim vPrefix as C="LAB"
            dim vSectn as C=""
            dim vLsect as C
            vLsect=comma_to_crlf("ADM,BLB,CYT,CHE,GEN,HEM,HIS,IMM,LIS,MIC,OFR,OPA,POC,QUA,SEN")
            dim vPol_no as C
            dim vGrouping as C
            dim vini_date as D=date()
            dim vrenew_date as D=date()+(365*5)
            dim vPol_name as C="Policy Test"
            dim vDc_number as C
            dim vPol_num_full as C
            dim vPriority as C
            dim vsign_level as C
            dim vSL as C="Supervisor"+crlf()+"Director"
            dim dlg_text as C
            
            dlg_text = <<%dlg%
            {background=#175,165,135}
            {xmargin=2,2}
            {frame=1,1}
            {region}
            Prefix: | [.10vprefix];
            Section: | [.10vsectn^+vLsect!combine];
            Grouping: | [.10vgrouping]  900 ;
            Policy Number: | [.10vpol_no!combine]  905;
            Initiate Date: | [%P=popup.calendar(dtoc(vini_date));I=popup.calendar%.16vini_date!combine];
            Renew_Date: | [%P=popup.calendar(dtoc(vrenew_date));I=popup.calendar%.16vrenew_date!combine];
            Policy Name: | [.30vpol_name];
            Signature Level: | [.20vsign_level^+vSL];
            Priority: | [.10vpriority!combine]  1-5  ;
            Full Policy Number: | [%r%.40vpol_num_full];
            Doc Control No.: | [%r%.40vdc_number];
            
            {endregion};
            {lf};
            {line=1,0}
            {lf};
            {justify=center}<10OK> <10Cancel>
            %dlg%
            
            dim vresult as C 
            RETRY:
            vresult=ui_dlg_box("Policy Entry", dlg_text, <<%code%
            IF a_dlg_button = "combine"
                vPol_num_full=vprefix+"_"+alltrim(vsectn)+"_"+alltrim(vPol_no)
                vDc_number=vPol_num_full+"_"+cdate(vini_date)+"_"+cdate(vRenew_date)
                a_dlg_button = ""
            END IF
            %code%)
            Regards,

            Ira J. Perlow
            Computer Systems Design


            CSDA A5 Products
            New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
            CSDA Barcode Functions

            CSDA Code Utility
            CSDA Screen Capture


            Comment


              #7
              Re: Trouble event trapping xdialog field values

              Thank you, gentlemen! With each of these great helps and examples, the opaqueness of xdialog is slowly becoming more transparent. Ira, your sode fit the bill perfectly, and clarified what Tom and Gabe were eluding to. Thanks much guys.
              Mike W
              __________________________
              "I rebel in at least small things to express to the world that I have not completely surrendered"

              Comment


                #8
                Re: Trouble event trapping xdialog field values

                Originally posted by G Gabriel View Post
                Actually Tom, it's a waste any way you look at it whether trapping one button or a dozen, trapping one event or a dozen. I don't know why it is in the help file.
                I don't mean to pick on Tom or G here because I've seen others make the same statement but I have to respectively disagree - unless the ONLY event you ever check for is the 'Change' event.

                Ira's comment that "Since all you need is a field's change event (which is the default), there is no need to specify event names ending in *, requiring the check for the event type. Just a simple event name will do" is absolutely correct in this instance but it doesn't address the issue of when you would actually want to use the "*" format for events. In the particular question presented in the thread, the user only needs to check the Change event but it would be unfair to give readers the impression that the Change event is the only event that would ever need to be checked. (Some may disagree but that is exactly the impression I would get from reading this thread if I didn't know better.)

                I used this simple xdialog script with variations on the "event_trigger" name for testing. Only two of my tests are discussed here since they are the only ones that really matter. The rest were done just to make sure I wasn't missing anything with some other variations on the event name.

                First example:
                Code:
                dlg_text = <<%dlg%
                Starting Object: [.10,1junk_val];
                Test Object: [.10,1test_val!event_trigger];
                {sp};
                {justify=center}<*15OK> <15Close>
                %dlg%
                 
                [COLOR=purple]DIM dlg_result as C
                [/COLOR]dlg_result = [COLOR=green]ui_dlg_box([/COLOR] "TEST", dlg_text, <<%code%
                IF a_dlg_button = "OK"
                    IF test_val = ""
                        [COLOR=green]ui_msg_box([/COLOR] "ENTRY REQUIRED", "Please enter some value in the Test Object or press 'Cancel' to quit." [COLOR=green])[/COLOR]
                        a_dlg_button = ""
                    END IF
                ELSE
                    IF a_dlg_button = "event_trigger"
                        [COLOR=green]trace.WriteLn([/COLOR] a_dlg_button [COLOR=green])
                [/COLOR]    END IF
                    a_dlg_button = ""
                END IF
                %code%)
                
                IF dlg_result <> "OK"
                    END'
                END IF
                 
                [COLOR=green]ui_msg_box([/COLOR] "OK PRESSED", "" [COLOR=green])
                [/COLOR]
                Using the script exactly as above:
                I pressed the Tab key to move to the field with the event_trigger and typed "asdf" then tabbed to the Close button and clicked it. The result in the Trace Window was:
                event_trigger
                event_trigger
                event_trigger
                event_trigger
                This is exactly what you would expect since the default is to only trigger the event on the Change action. Since I typed "asdf", there were 4 changes - one for each letter - and the event was triggered 4 times.

                The problem now is that I want to trap something else like the killfocus event or the dblclick event. This can only be done by adding the * on the end of the event name. I like to do as the A5 examples show and add _* but the underscore is not necessary - I just think it's a bit easier to read.

                Once the * is added on the end, ALL possible events for that object type (yes, some object types have different events) will be returned.

                Using the above script but changing "trigger_event" to "trigger_event_*" in the dlg_text string and testing using exactly the same actions results in these events in the Trace window:
                event_trigger_setfocus
                event_trigger_cursor
                event_trigger_changing
                event_trigger_change
                event_trigger_changing
                event_trigger_change
                event_trigger_changing
                event_trigger_change
                event_trigger_changing
                event_trigger_change
                event_trigger_cursor
                event_trigger_killfocus
                That's a whole lot more events. AND, if you were to double click in the field before clicking the close button, you would get one more event (second to last line):
                event_trigger_setfocus
                event_trigger_cursor
                event_trigger_changing
                event_trigger_change
                event_trigger_changing
                event_trigger_change
                event_trigger_changing
                event_trigger_change
                event_trigger_changing
                event_trigger_change
                event_trigger_cursor
                event_trigger_dblclick <-----
                event_trigger_killfocus

                Normally the "dblclick" event won't be much use in a single field as in this example but it can be very user friendly in a multi-line select box.

                So, how do you trap only the "dblclick" event? The only reasonable way I can think of is to use the "left()" command. (There are other ways but this seems the most reasonable.)

                Second example - using "left( a_dlg_button..." to trap the dblclick event:
                Code:
                ok_pressed = .F.
                dlg_text = <<%dlg%
                Starting Object: [.10,1junk_val];
                Test Object: [.10,1test_val!event_trigger_*];
                {sp};
                {justify=center}<*15OK> <15Close>
                %dlg%
                 
                [COLOR=purple]DIM dlg_result as C[/COLOR]
                dlg_result = [COLOR=green]ui_dlg_box([/COLOR] "TEST", dlg_text, <<%code%
                [COLOR=black]IF a_dlg_button = "OK"
                    IF test_val = ""
                        [COLOR=green]ui_msg_box([/COLOR] "ENTRY REQUIRED", "Please enter some value in the Test Object or press 'Cancel' to quit." [COLOR=green])[/COLOR]
                        a_dlg_button = ""
                    ELSE
                        [COLOR=blue]'Since we are also testing for the dblclick now, it's easier if we also handle the OK button a little differently.[/COLOR]
                        ok_pressed = .T.
                    END IF
                ELSEIF [COLOR=green]left([/COLOR] a_dlg_button, 14 [COLOR=green])[/COLOR] = "event_trigger_"
                    IF a_dlg_button = "event_trigger_dblclick"[/COLOR]
                [COLOR=blue]        'Reset ok_pressed here so we can test it when the xdialog closes.[/COLOR]
                [COLOR=black]        ok_pressed = .T.[/COLOR]
                [COLOR=black]    ELSE[/COLOR]
                [COLOR=blue]        'Set a_dlg_button to blank so the dialog won't quit.[/COLOR]
                [COLOR=black]        a_dlg_button = ""[/COLOR]
                [COLOR=black]    END IF[/COLOR]
                [COLOR=black]END IF[/COLOR]
                %code%)
                 
                IF .not. ok_pressed    [COLOR=blue]'If the OK button was handled normally, we would also have to test for: [I] .and. dlg_result <> "OK"[/I][/COLOR]
                    END'
                END IF
                 
                [COLOR=green]ui_msg_box([/COLOR] "OK PRESSED", "" [COLOR=green])[/COLOR]
                [COLOR=red][COLOR=#000000][/COLOR][/COLOR]



                I don't know of any other reasonable way to test for all the other events such as setfocus, changed, changing, killfocus, and dblclick. And, yes, I use the Killfocus and Dblclick events on a regular basis in my xdialogs so I feel that these are important.

                FWIW: Personally, I would never use such a long base name as "event_trigger_". It takes too long to type and takes up too much real estate but I used it here for clarity. Actually, "event_trigger_basename_" might have been even more appropriate but I just couldn't bear to do that. Most of my event triggers are a 3 letter abbreviation that is somewhat indicative of the variable in the object. By sticking to a 3 letter name I can simply invoke my keyboard macro to type most of the IF statement.

                Comment


                  #9
                  Re: Trouble event trapping xdialog field values

                  I have nothing against the "*". Its use is proper.
                  What is not needed is:
                  If left(a_dlg_button,5)= "dcnx_"
                  end if

                  Comment


                    #10
                    Re: Trouble event trapping xdialog field values

                    Hi Cal,

                    Originally posted by CALocklin View Post
                    Ira's comment that "Since all you need is a field's change event (which is the default), there is no need to specify event names ending in *, requiring the check for the event type. Just a simple event name will do"
                    I see how one might interpret the above as not needing other events, but I was saying "since all YOU need" meaning for this specific case only. I use double clicks all the time as well as many others.

                    While you didn't mention it in this thread, for others, the default event name for change if not specified is generally the text of the object, e.g. if the text of a button is "Do this", then the event name is "Do this". However, many object names have spaces, hot keys "&", and I typically want to separate the text from the event name (as the text changes over development), so I typically will specify the explicit event name after the "!",

                    I also tend to agree with using the "_*" format to be more readable and discernible.

                    As for using left() to process the events, it really depends. You can process each event type as a separate section of code, or do it as a subsection. e.g. Double-Clicks that go to a web page really have nothing to do with the other events in the dialog box. If you use both ways, do the more explicit ones 1st, or you'll never get to that code, e.g.
                    Code:
                    ELSEIF a_dlg_button = "event_trigger_dblclick"
                        Sys_open("http://www.google.com")       
                        a_dlg_button = ""
                    ELSEIF left(  a_dlg_button, 14 ) = "event_trigger_"
                        IF a_dlg_button = "event_trigger_killfocus"
                             ' some code here
                        END IF
                    END IF
                    Regards,

                    Ira J. Perlow
                    Computer Systems Design


                    CSDA A5 Products
                    New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                    CSDA Barcode Functions

                    CSDA Code Utility
                    CSDA Screen Capture


                    Comment


                      #11
                      Re: Trouble event trapping xdialog field values

                      Originally posted by csda1 View Post
                      Code:
                      ELSEIF a_dlg_button = "event_trigger_dblclick"
                          Sys_open("http://www.google.com")       
                          a_dlg_button = ""
                      ELSEIF left(  a_dlg_button, 14 ) = "event_trigger_"
                          IF a_dlg_button = "event_trigger_killfocus"
                               ' some code here
                          END IF
                      END IF
                      That's where the waste is.
                      Code:
                      If Johnny's eyes="green"
                         if Johnny's eyes="green".and.Johnny's eyes="big"
                          do this
                          end if
                      end if
                      What is the purpose of the outer if() statement?
                      Nothing.
                      You tested it again in the inner if() statement.


                      One more time:
                      Code:
                      if left(x,2)="AB"
                         if x="ABC"
                         do something
                         end if
                      end if
                      Any reason why you want to test for left(x,2) if you are going to test for the whole x?
                      No reason.

                      Comment


                        #12
                        Re: Trouble event trapping xdialog field values

                        Originally posted by G Gabriel View Post
                        Any reason why you want to test for left(x,2) if you are going to test for the whole x?
                        Yes, you could just test for after the "_" in the innerloop with a substr() command or similar, but it actually is slower (by a small amount) than testing the whole event name. But there are many instances of my code and for many others where there is common code applied to some or all of the sub events, so in that case you test for the main part of the event, then process the sections as needed, e.g.

                        Code:
                        ELSEIF a_dlg_button = "event_trigger_dblclick"
                            Sys_open("http://www.google.com")       
                            a_dlg_button = ""
                        ELSEIF left(  a_dlg_button, 14 ) = "event_trigger_"
                        
                            ' some code here to do before processing these subevents
                        
                            IF a_dlg_button = "event_trigger_killfocus"
                                 ' some code here
                            ELSEIF a_dlg_button = "event_trigger_killfocus"
                                ' some code here
                            END IF
                        
                            ' more code here
                        
                            IF a_dlg_button = "event_trigger_killfocus"
                                ' some code here specific to killfocus after "more code here"
                            END IF
                        
                            ' cleanup code here
                        
                        END IF
                        Regards,

                        Ira J. Perlow
                        Computer Systems Design


                        CSDA A5 Products
                        New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                        CSDA Barcode Functions

                        CSDA Code Utility
                        CSDA Screen Capture


                        Comment


                          #13
                          Re: Trouble event trapping xdialog field values

                          Originally posted by csda1 View Post
                          Yes, you could just test for after the "_" in the innerloop with a substr() command or similar, but it actually is slower
                          Sure you can, which would be double waste not to mention and as you said, slower.

                          Originally posted by csda1 View Post
                          Code:
                          ELSEIF left(  a_dlg_button, 14 ) = "event_trigger_"
                          
                              ' some code here to do before processing these subevents
                          Not really sure what "some code here.." would be?
                          The only thing you gained from this test is knowing which control you are in and since no specific event was specified, you could just test for any event using the whole text instead of left().
                          It's meaningless.

                          Comment


                            #14
                            Re: Trouble event trapping xdialog field values

                            Originally posted by G Gabriel View Post
                            What is the purpose of the outer if() statement?
                            Nothing.
                            You tested it again in the inner if() statement.
                            Originally posted by csda1 View Post
                            But there are many instances of my code and for many others where there is common code applied to some or all of the sub events, so in that case you test for the main part of the event, then process the sections as needed,
                            And at the very least to catch all the events that are returned by '_*' and not used so that a_dlg_button can be reset. Especially in an modal dialog.
                            Code:
                            IF left( a_dlg_button, 14 ) = "event_trigger_"
                            
                                IF a_dlg_button = "event_trigger_killfocus"
                                     ' do something
                                END IF
                            
                                a_dlg_button = ""
                            
                            END IF
                            Tim Kiebert
                            Eagle Creek Citrus
                            A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                            Comment


                              #15
                              Re: Trouble event trapping xdialog field values

                              Ok.. I am going to find a nearby wall and bang my head:

                              Code:
                              IF left( a_dlg_button, 14 ) = "event_trigger_"
                              
                                  IF a_dlg_button = "event_trigger_killfocus"
                                       ' do something
                                  END IF
                              
                                  a_dlg_button = ""
                              
                              END IF
                              Is the same (with less code & less work on alpha's part) as:
                              Code:
                              IF a_dlg_button = "event_trigger_killfocus"
                                       ' do something
                              a_dlg_button = ""
                              END IF
                              I believe Selwyn made the same comment before.

                              Comment

                              Working...
                              X