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

Query on use of ui_modeless_dlg_refresh()

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

    Query on use of ui_modeless_dlg_refresh()

    I have a thread running in the background. I also have a modeless dialog box running that displays data collected by the Thread.
    To get the Xdialog display updated, I use ui_modeless_dlg_refresh() followed by sys_send_keys("{End}").
    This works as intended, but it would appear that the whole system is refreshed.
    ie if I am currently using another application or even this message-board, the current window is also refreshed and acts as if the {End} key has been pressed in this application as well. Is there a way to stop this.
    the {End} key is sent in the Xdialog to put last record into view. If this is the culprit, what would be a way of reseting the Xdialog and going to the {End} of only the Xdialog list?

    the full code is thus:

    Code:
    DIM SHARED Var1 as C
    DIM SHARED varC_result as C
    IF thread_is_running("sbs_monitor") THEN
    	enable_start = .f.
    	enable_stop  = .t.
    ELSE
    	enable_start = .t.
    	enable_stop  = .f.
    END IF
    DIM Var1_rl_def as C
    Var1_rl_def = "kl=sbsmonitor,{keylist_build('H=.030,1:0[],2:10[Reg],3:4[Type]',''+padl(ltrim(str(recno(),7,0)),10,\"0\"),''+padl(ltrim(str(recno(),7,0)),10,\"0\"),left(''+Reg,10),left(''+Icaotypecode,6))}{}"
    varC_result = ui_modeless_dlg_box("SBS Monitor",<<%dlg%
    {font=Dotum,8}
    {can_exit=Close}
    {interval=60}
    {timer=refresh}
    {region}
    [%@Var1_rl_def%.30,7Recno_Value];
    {endregion};
    {line=1,0};
    <*8Start?enable_start><8Stop?enable_stop><8Close>
    %dlg%,<<%code%
    IF a_dlg_button = "Start" THEN
    	IF .not. thread_is_running("sbs_monitor") THEN
    		script_play("SBSMonitorThread")
    	END IF
    	enable_start = .f.
    	enable_stop  = .t.
    END IF
    IF a_dlg_button = "Stop" THEN
    	IF thread_is_running("sbs_monitor") THEN
    		script_play("stop_sbs_thread")
    	END IF
    	enable_start = .t.
    	enable_stop  = .f.
    END IF
    IF a_dlg_button = "Refresh" THEN
    	ui_modeless_dlg_refresh("SBS Monitor")
    	sys_send_keys("{End}")
    END IF
    IF a_dlg_button = "Close" THEN
    	ui_modeless_dlg_close("SBS Monitor")
    END IF
    %code%)
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

    #2
    Re: Query on use of ui_modeless_dlg_refresh()

    Graham,

    You have to set the selected item in the list to the last item, and then the Xdialog will automatically put focus there. Here is an example:
    Code:
    fruits=<<%lst%
    apples
    oranges
    pears
    bananas
    pineapples
    strawberries
    figs
    dates
    plums
    grapefruit
    honeydew melon
    canteloupe
    %lst%
    
    i=0
    getFruits=<<%code%
    fruitlist=word(fruits,1,crlf(),i)
    %code%
    evaluate_template(getFruits)
    
    ui_modeless_dlg_box("SBS Monitor",<<%dlg%
    {font=Dotum,8}
    {can_exit=Close}
    {startup=clock}
    {interval=3}
    {timer=clock}
    {region}
    [%M%.20,10selection^#fruitlist];
    {endregion};
    {line=1,0};
    <8Close>
    %dlg%,<<%code%
    IF a_dlg_button = "clock" THEN
    	i=i+1
    	evaluate_template(getFruits)
    	selection=word(fruitlist,w_count(fruitlist,crlf()),crlf())
    	ui_modeless_dlg_refresh("SBS Monitor")
    	
    END IF
    IF a_dlg_button = "Close" THEN
    	ui_modeless_dlg_close("SBS Monitor")
    END IF
    %code%)

    Comment


      #3
      Re: Query on use of ui_modeless_dlg_refresh()

      Thanks Peter,
      I think I got there myself. I have rewitten the background Thread to write to a global array and then modified the Multi-choice example in the Xdialog Help to also read the same global Array. It works better than my first effort as I have set all events against a dlg_button. I still cannot work out how to point the display to the last array entry after the timed Refresh as the sys_send_keys("{end}") is applied to which every application has focus at the time of the refresh!!. Any suggestions welcome

      I had to "fudge" the issue in that I had to set the array as:

      Code:
      DIM Global SbsMonitorArray[2000] as c
      and concatenate the fields read from table "Logging" and written to SbsMonitorArray[incr] thus:

      Code:
      IF left(bsOutput,3) = "AIR" THEN
      	tbl = table.open("logging")
      	idx = tbl.index_primary_put("ModeS")
      	rec = tbl.fetch_find(substr(bsOutput,at(",",bsOutput,4)+1,6))
      	if (rec > 0 ) .and. isblank("tbl.as") then
      		SbsMonitorArray[incr] = padr(trim(tbl.reg),12," ")+padr(trim(tbl.icaotypecode),4," ")+tbl.unique '' +crlf()
      		incr = incr + 1
      	end if	
      	tbl.close()
      end if
      Then display in the Modeless dialog as:

      Code:
      [.13,10list1_selected^#SbsMonitorArray];
      and finally use the following code to strip out the value I needed:
      Code:
      FOR each LogEntry in log_list
      x = ix.find(substr(LogEntry,17))
      t.fetch_goto(x.record)
      t.change_begin()
      t.as = t.reg
      t.where = "PAGANHILL SBS"
      t.when = Date()
      t.change_end(.t.)
      Next
      Having read through "Xdialog Help" I cannot see the way to use an Array with multiple dimensions.

      i.e.
      Code:
      DIM Global SbsMonitorArray[2000,3] as c
      ..
      ..
      ..
      Code:
      SbsMonitorArray[incr,1] = tbl.reg
      SbsMonitorArray[incr,2] = tbl.icaotypecode
      SbsMonitorArray[incr,3] = tbl.unique
      ..
      ..
      ..
      what is the equivalent of
      Code:
      [.13,10list1_selected^#SbsMonitorArray];
      to use for a multi-dimensioned array? if it can be done at all?


      Finally the complete scripts:

      Background Thread:
      Code:
      'Date Created: 04-Jan-2007 05:52:34 PM
      'Last Updated: 08-Jan-2007 02:31:58 PM
      'Created By  : Graham Wickens
      'Updated By  : Graham Wickens
      thread_create("SBS_monitor_Array",<<%code%
      xbasic_error_log("d:\My Databases\SBS\txt\thread_error_log.txt")
      dim thread_run_flag as l = .t.
      dim global SbsMonitorArray[2000] as c
      incr = 1
      dim bs as p = sockets.open("127.0.0.1",30003,"C")
      while thread_run_flag
      dim bsOutput as c = bs.readline()
      IF left(bsOutput,3) = "AIR" THEN
      	tbl = table.open("logging")
      	idx = tbl.index_primary_put("ModeS")
      	rec = tbl.fetch_find(substr(bsOutput,at(",",bsOutput,4)+1,6))
      	if (rec > 0 ) .and. isblank("tbl.as") then
      		SbsMonitorArray[incr] = padr(trim(tbl.reg),12," ")+padr(trim(tbl.icaotypecode),4," ")+tbl.unique 
      		incr = incr + 1
      	end if	
      	tbl.close()
      end if
      end while
      bs.close()
      %code%)


      Script to Monitor Thread Array:

      Code:
      'Date Created: 12-Jun-2002 07:49:13 AM
      'Last Updated: 08-Jan-2007 02:29:31 PM
      'Created By  : Selwyn
      'Updated By : Graham
      dim Global SbsMonitorArray[2000] as c
      dim log_list[1500] as c
      dim list1_selected as n = 1
      dim list2_selected as n = 1
      IF thread_is_running("sbs_monitor_array") THEN
      	enable_start = .f.
      	enable_stop  = .t.
      ELSE
      	enable_start = .t.
      	enable_stop  = .f.
      END IF
      enable_add = .t.
      enable_log = .f.
      enable_remove = .f.
      ui_modeless_dlg_box("SBS Monitor",<<%dlg%
      {startup=
      {interval=60}
      {timer=refresh}
      {region0}
      {region1}
      {region2}
      Tracked Needs;
      {font=Courier New,8}
      [.13,10list1_selected^#SbsMonitorArray];
      {endregion2}|
      {region20}{endregion20}|
      {region3}
      {lf};
      {font=Arial,8}
      <10Add?enable_add>;
      <10Add All?enable_add>  ;
      <10Remove?enable_remove>;
      <10Remove All?enable_remove>
      {font=Courier New,8}
      {endregion3}|
      {region20}{sp};{endregion20}|
      {region4}
      {font=Arial,8}
      Logging;
      {font=Courier New,8}
      [.13,10list2_selected^#log_list];
      {endregion4}
      {endregion1}
      {endregion0}
      {region5}
      {lf};
      {font=Arial,8}
      <10Start?enable_start>;
      <10Stop?enable_stop>;
      <10Log?enable_log>;
      <10Close>
      {font=Courier New,8}
      {endregion5}
      %dlg%,<<%code%
      IF a_dlg_button = "Add" THEN
      	a_dlg_button = ""
      	IF list1_selected > 0 THEN
      		first_empty_on_list2 = log_list.first_empty()
      		log_list[first_empty_on_list2] = SbsMonitorArray[list1_selected]
      		SbsMonitorArray.delete(list1_selected,1)
      		list2_selected = first_empty_on_list2
      		'after adding an entry, move the focus up to previous record,
      		'unless you were already on the first record.
      		IF SbsMonitorArray[list1_selected] = "" .and. list1_selected > 1 THEN
      			list1_selected = list1_selected-1
      		ELSE
      			list1_selected = list1_selected
      		END IF
      		'turn on the Remove flags
      		enable_log = .t.
      		enable_remove = .t.
      		'if there are no more entries in list1, turn off Add flags
      		IF SbsMonitorArray[list1_selected] = "" THEN
      			enable_add = .f.
      		END IF
      	END IF
      	enable_log = .t.
      END IF
      IF a_dlg_button = "Remove" THEN
      	a_dlg_button = ""
      	IF list2_selected > 0 THEN
      		first_empty_on_list1 = SbsMonitorArray.first_empty()
      		value_to_remove = log_list[list2_selected]
      		SbsMonitorArray[first_empty_on_list1] = log_list[list2_selected]
      		log_list.delete(list2_selected,1)
      		SbsMonitorArray.sort("ab")
      		list1_selected = SbsMonitorArray.find(value_to_remove)
      		IF list2_selected > 1 THEN
      			list2_selected = list2_selected-1
      		ELSE
      			list2_selected = 1
      		END IF
      		IF log_list[list2_selected] = "" THEN
      			enable_remove = .f.
      			enable_log = .f.
      		END IF
      		enable_add = .t.
      	END IF
      END IF
      IF a_dlg_button = "Add all" THEN
      	a_dlg_button = ""
      	tempstring = log_list.dump("r")+SbsMonitorArray.dump("r")
      	log_list.clear()
      	log_list.initialize(tempstring)
      	SbsMonitorArray.clear()
      	list2_selected = 1
      	enable_remove = .t.
      	enable_add = .f.
      	enable_log = .t.
      END IF
      IF a_dlg_button = "Remove all" THEN
      	a_dlg_button = ""
      	tempstring = SbsMonitorArray.dump("r")+log_list.dump("r")
      	log_list.clear()
      	SbsMonitorArray.initialize(tempstring)
      	list1_selected = 1
      	enable_remove = .f.
      	enable_add = .t.
      	enable_log = .f.
      END IF
      IF a_dlg_button = "Start" THEN
      	IF .not. thread_is_running("SBS_monitor_Array") THEN
      		script_play("SBSMonitorArrayThread")
      	END IF
      	enable_start = .f.
      	enable_stop  = .t.
      END IF
      IF a_dlg_button = "Stop" THEN
      	IF thread_is_running("sbs_monitor_array") THEN
      		script_play("stop_array_thread")
      	END IF
      	enable_start = .t.
      	enable_stop  = .f.
      END IF
      IF a_dlg_button = "Refresh" THEN
      	ui_modeless_dlg_refresh("SBS Monitor")
      END IF
      IF a_dlg_button = "Close" THEN
      	ui_modeless_dlg_close("SBS Monitor")
      	file_pointer = file.create("d:\My Databases\SBS\txt\SBS_Monitor_Array_Report"+time("yyyyMMd@0h0m0s")+".txt", FILE_RW_EXCLUSIVE)
      	file_pointer.write_line("SBS Report for "+time("Weekday Mon yyyy at 0h-0m-0s"))
      	FOR each LogEntry in log_list
      		IF LogEntry <> "" THEN
      			file_pointer.write_line("Seen: "+LogEntry)
      		END IF
      	NEXT
      	FOR each MonEntry in SbsMonitorArray
      		IF MonEntry <> "" THEN
      			file_pointer.write_line("Need Tracked: "+MonEntry)
      		END IF
      	next
      	file_pointer.flush()
      	file_pointer.close()
      END IF
      IF a_dlg_button = "Log" THEN
      	t = table.open("Logging",file_rw_shared)
      	ix = t.index_primary_put("unique")
      	FOR each LogEntry in log_list
      		x = ix.find(substr(LogEntry,17))
      		t.fetch_goto(x.record)
      		t.change_begin()
      		t.as = t.reg
      		t.where = "PAGANHILL SBS"
      		t.when = Date()
      		t.change_end(.t.)
      	next
      END IF
      %code%)
      end
      --
      Support your local Search and Rescue Unit, Get Lost!

      www.westrowops.co.uk

      Comment


        #4
        Re: Query on use of ui_modeless_dlg_refresh()

        Graham,

        I love the way you make this tremendous progression. Even I can learn a lot from your code. Thank you for that. :)
        Marcel

        I hear and I forget. I see and I remember. I do and I understand.
        ---- Confusius ----

        Comment


          #5
          Re: Query on use of ui_modeless_dlg_refresh()

          Thanks Marcel,
          I always try and show my results, as maybe someone else might need to do this.
          --
          Support your local Search and Rescue Unit, Get Lost!

          www.westrowops.co.uk

          Comment

          Working...
          X