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

Socket Programming

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

    #31
    Re: Socket Programming

    I've given it a go and have a "sort of" working dialog, but am unsure as if this is the best way to do it.
    Code:
    DIM SHARED Var1 as C
    DIM SHARED varC_result as C
    DIM Var1_rl_def as C 
    Var1_rl_def = "kl=sbsmonitor,{keylist_build(\"H=.025,1:10[Reg],2:6[Type],3:3[Flag]\",''+Reg,left(''+Reg,10),left(''+Icaotypecode,6),left(''+Flag,3))}{}"
    varC_result = ui_modeless_dlg_box("SBS Monitor",<<%dlg%
    {font=Dotum,8}
    {region}
    [%@Var1_rl_def%.40,5Var1];
    {endregion};
    {line=1,0};
    <*15Start> <15Stop>
    %dlg%,<<%code%
    if a_dlg_button = "Start" then
    	if .not. thread_is_running("sbs_monitor") then
    		script_play("SBSMonitorThread")
    	end if	
    end if	
    if a_dlg_button = "Stop" then
    	if thread_is_running("sbs_monitor") then
    		script_play("SBSThread_stop")
    	end if
        ui_modeless_dlg_close("SBS Monitor")
    end if
    %code%)
    1) the dialog is expecting me to select a record to pass to its variable, not what I am doing.

    2) I can't use the modeless dialog to flag a particular record for later use in an update process run after closing the application.

    3) Where do I put the refresh {Timer}{Interval} and how do I move the display to last record after the refresh?
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

    Comment


      #32
      Re: Socket Programming

      Hi Marcel/Tim,

      Some progress being made, I think the thread is working just fine now. I realised that I did not need the Table open all the time so I adjusted the code accordingly: Having said that I realise that I do not cater for value not being found in tbl.fetch_find() (just corrected lines in blue Italics)

      Code:
      thread_create("SBS_monitor",<<%code%
      xbasic_error_log("d:"+chr(92)+"My Databases"+chr(92)+"SBS"+chr(92)+"txt"+chr(92)+"thread_error_log.txt")
      dim thread_run_flag as l = .t.
      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))
              [I][COLOR="Blue"]if (rec > 0) then[/COLOR][/I]
      	if isblank("tbl.as") then
      		sbs = table.open("sbsMonitor")
      		sbs.enter_begin(.t.)
      		sbs.modes = tbl.modes
      		sbs.reg = ut(tbl.reg)
      		sbs.icaotypecode = tbl.icaotypecode
      		sbs.enter_end(.t.)
      		sbs.close()
      	end if
              [I][COLOR="Blue"]end if[/COLOR][/I]
      	tbl.close()
      end if
      end while
      bs.close()
      %code%)
      As for the modeless xdialog box, I am almost there, just one little snag that I can't seem to sort, changing the Flag from .t. to .f. or vica-versa. I usually number the differing versions of any script, this one is up to version 9 and still counting:)
      Code:
      DIM SHARED Var1 as C
      DIM SHARED varC_result as C
      DIM Var1_rl_def as C
      Var1_rl_def = "kl=sbsmonitor,{keylist_build(\"H=.025,1:10[Reg],2:6[Type],3:3[Flag]\",''+Reg,left(''+Reg,10),left(''+Icaotypecode,6),left(''+Flag,3))}{}"
      varC_result = ui_modeless_dlg_box("SBS Monitor",<<%dlg%
      {font=Dotum,8}
      {region}
      [%@Var1_rl_def%.40,5Var1];
      {endregion};
      {line=1,0};
      <*15Start> <15Stop>
      %dlg%,<<%code%
      IF var1 <> "" THEN
      	sbm = table.open("sbsmonitor")
      	IF exist(ut(sbm.REG),"sbsmonitor","regfind") THEN
      		idx = sbm.index_primary_put("regfind")	
      		x  = idx.find(ut(sbm.reg))
      		sbm.fetch_goto(x.record)
      		sbm.change_begin()
      		IF sbm.flag = .f.
      			sbm.flag = .t.
      		ELSE
      			sbm.flag = .f.
      		END IF
      		sbm.change_end(.t.)
      	END IF
      	sbm.close()
      END IF
      if a_dlg_button = "Start" then
      	if .not. thread_is_running("sbs_monitor") then
      		script_play("SBSMonitorThread")
      	end if
      end if
      if a_dlg_button = "Stop" then
      	if thread_is_running("sbs_monitor") then
      		script_play("SBSThread_stop")
      	end if
      	ui_modeless_dlg_close("SBS Monitor")
      end if
      %code%)
      not happy with the double call to the index to get the correct record (I've opened another thread on this one).
      Last edited by Graham Wickens; 01-04-2007, 02:57 PM. Reason: Added code correction later
      --
      Support your local Search and Rescue Unit, Get Lost!

      www.westrowops.co.uk

      Comment


        #33
        Re: Socket Programming

        Nice progression. Can't follow the big picture anymore :) just details.

        Code:
        xbasic_error_log("d:"+chr(92)+"My Databases"+chr(92)+"SBS"+chr(92)+"txt"+chr(92)+"thread_error_log.txt")
        Code:
        xbasic_error_log("d:\\My Databases\\SBS\\txt\\thread_error_log.txt")
        Is simpler...
        Marcel

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

        Comment


          #34
          Re: Socket Programming

          Graham,
          Here's an example of starting and stopping a timed activity in a ui_modeless_dlg_box:
          Code:
          'Date Created: 29-Dec-2006 07:58:56 PM
          'Last Updated: 02-Jan-2007 09:02:28 PM
          'Created By  : Peter Wayne
          'Updated By  : Peter Wayne
          
          dim dlg_title as c="Lucky Number"
          lucky=0
          
          dlg_expanded=<<%dlg%
          {font=Tahoma,10}
          {units=f}
          {interval=3}
          {timer=time}
          {startup=time}
          {can_exit=Close}
          {region}
          The lucky number is {text=10,1lucky};
          {endregion}
          {line=1,0};
          {region}
          <Pause!pause> <Close!Close>
          {endregion};
          %dlg%
          
          dlg_contracted=<<%dlg%
          {can_exit=Close}
          <Start!expand> <Close!close>;
          %dlg%
          
          events=<<%code%
          if a_dlg_button="time" then 
             lucky=int(rand()*999999)
          	ui_modeless_dlg_refresh(dlg_title,.f.)
          end if
          if a_dlg_button="Close" then
              ui_modeless_dlg_close(dlg_title)
          end if 
          if a_dlg_button="pause" then
              ui_modeless_dlg_box(dlg_title,dlg_contracted,events)
          end if
          if a_dlg_button="expand" then
              ui_modeless_dlg_box(dlg_title,dlg_expanded,events)
          end if
          %code%
          
          ui_modeless_dlg_box(dlg_title,dlg_contracted,events)

          Comment


            #35
            Re: Socket Programming

            Originally posted by Marcel Kollenaar View Post
            Nice progression. Can't follow the big picture anymore :) just details.

            Code:
            xbasic_error_log("d:"+chr(92)+"My Databases"+chr(92)+"SBS"+chr(92)+"txt"+chr(92)+"thread_error_log.txt")
            Code:
            xbasic_error_log("d:\\My Databases\\SBS\\txt\\thread_error_log.txt")
            Is simpler...
            Actually the correct Xbasic syntax is even simpler...
            Code:
            xbasic_error_log("d:\My Databases\SBS\txt\thread_error_log.txt")
            Your code will work Marcel, but only because Windows treats the \\ as \ in the path.

            Lenny Forziati
            Vice President, Internet Products and Technical Services
            Alpha Software Corporation

            Comment


              #36
              Re: Socket Programming

              I seem to have got it all working after a few tweaks here and there, one was changing the Table.open() command in the Thread to have FILE_RW_SHARED because when the modeless dlg to display the table was open, the thread could not add new records to that table.

              I understand the {timer} etc now, really just pseudo buttons!

              One last problem, when the modeless dialog refreshes the xdialog, although it does refresh the data with the latest entry at the top of the list, the cursor (or what ever controls lines in an Xdialog Record List) does not restart at the top of the file, to see the top most record I have to click on the vertical bar for it to be in view. Anyone got a suggestion on how this might be done automatically by the refresh?
              Last edited by Graham Wickens; 01-05-2007, 01:43 PM. Reason: correction to grammar
              --
              Support your local Search and Rescue Unit, Get Lost!

              www.westrowops.co.uk

              Comment


                #37
                Re: Socket Programming

                Your code will work Marcel, but only because Windows treats the \\ as \ in the path.
                Lenny, I thought the '\' has to be 'escaped'.
                Marcel

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

                Comment


                  #38
                  Re: Socket Programming

                  Originally posted by Marcel Kollenaar View Post
                  Lenny, I thought the '\' has to be 'escaped'.
                  While \ is the escape character in Xbasic, it is only treated as such when required. If it wouldn't actually escape anything, such as in the middle of your file path, it is treated as a plain character.

                  "c:\" - Not valid because the backslash escapes what was intended to be the closing quote
                  "c:\\" - The backslash is escaped so the closing quote remains unescaped and a valid string is built
                  "c:" + chr(92) - The ASCII character 92 is used in place of the backslash to avoid escaping issues
                  "c:\\myfile.txt" - While this has built a valid string, it is probably not what you expected - c:\\myfile.txt
                  "c:\myfile.txt" - The backslash doesn't escape an m since it has no reason to do so. In this case it is not treated as an escape character and can be used as-is.

                  Lenny Forziati
                  Vice President, Internet Products and Technical Services
                  Alpha Software Corporation

                  Comment


                    #39
                    Re: Socket Programming

                    Thanks Lenny. I'm back on track. When it is an expression I need to escape it.

                    From the help!
                    Adding Backslash Characters
                    If you need to include a backslash in an expression, use a second backslash to escape it.

                    Code:
                    myvar = "\\"
                    ? myvar
                    = "\"
                    Or on the subject:

                    Code:
                    dim err_log as C
                    err_log := "d:[COLOR="Red"]\\[/COLOR]My Databases[COLOR="red"]\\[/COLOR]SBS[COLOR="red"]\\[/COLOR]txt[COLOR="red"]\\[/COLOR]thread_error_log.txt"
                    xbasic_error_log(err_log)
                    Would be correct.
                    Marcel

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

                    Comment


                      #40
                      Re: Socket Programming

                      Cor!,

                      thats much neater than using "d:"+chr(92)+"foldername" ain't it ;)
                      --
                      Support your local Search and Rescue Unit, Get Lost!

                      www.westrowops.co.uk

                      Comment

                      Working...
                      X