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

watch for file

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

    watch for file

    Hi All

    I am not sure how to do this but I am sure it can be done,

    basically I want to run a back ground process that watches a directory and when a file appears import the file into Alpha and run another process.

    so this is the scenario

    a customer enters a order on their main frame
    main frame posts a file of the order to a directory
    Alpha is watching directory for a file
    File appears Alpha imports file
    Alpha deletes file from directory
    Alpha watches directory

    This will save lots of double entry a some of my customers

    Thanks

    Andy

    #2
    Re: watch for file

    Andy:

    This code (or a similar version) runs in the OnTimer of a background form. It watches for any file in the "LaunchImaging" folder and when it appears, starts up imaging software. The even is set to fire every 5 seconds, I think.

    Code:
    dim shared working as L
    if .not. working then
    working = .T.
    dim app_path as c
    app_path = A5.Get_Path() + Chr(92)
    pat_path = app_path + "LaunchImaging" + Chr(92)
    
    'Get the location of the imaging executable
    ti = table.open(app_path + "Image_Setup")
    img_exe = alltrim(ti.img_exe_path)
    ti.close()
    'check for file		
    flist = FileFind.get(app_path + "LaunchImaging" + Chr(92) +\ "*.*",FILE_FIND_NORMAL+FILE_FIND_NOT_DIRECTORY,"N")
    if flist <> "" then
    patfilename = word(flist,1,Crlf())
    exefile = Chr(34)+img_exe+Chr(34)+" -I"+Chr(32) + Chr(34) + pat_path +\ patfilename + Chr(34)
    'Launch the external app
    sys_shell_wait(exefile,.T.)
    'Remove the pat file
    file.remove(pat_path + patfilename)
    end if
    working = .F.
    end if
    Where the code above launches the external app, you would run your import. The working variable stops the import of another file, by this user, while processing is going on.
    Finian

    Comment


      #3
      Re: watch for file

      hi Finian

      I found this function which says it does what i want, but I seem to be having a few problems

      file.watch_create("lchem","C:\import data","T","script_play("\newdeltransimport\")")

      my error is

      ---------------------------
      Alpha Five
      ---------------------------
      Script contained errors.

      Error at line: 1, column: 1



      Error: Expected value
      ---------------------------
      OK
      ---------------------------
      any ideas where I am going wrong

      Andy

      Comment


        #4
        Re: watch for file

        It looks like an error in the help file. The

        script_play("\

        should be

        script_play(\"

        I did the original version of that code in V4.5. It's the second time in a week I posted code I've been using since V4 only to find V5 or later functions that encapsulate it. Oh well.
        Finian

        Comment


          #5
          Re: watch for file

          thanks Finian

          thats working now

          Andy

          Comment


            #6
            Re: watch for file

            Hi Andy / Finian,

            I'm looking for something similar Andy. You hinted me to look at FILE.WATCH_CREATE(). I think this is what im after.
            The difficulty comes in when I want to run play a script "script_play("\script_to_run\")". What script do I need to create to obtain files belonging to only the customer which I opened in the form, stored in a folder containing primairely information about that customer.

            So shortly, how to connect an external windows folder to a customer containing a list with files? I want them to appear in the customer form, retrieving information from that external file.

            Anyone how could help me?!

            Thanks!
            Evert

            Comment


              #7
              Re: watch for file

              First you need to create a script that performs the sequence that you described. You don't give us much to go on.

              For the sake of description, assume that the form/table contains a field (cust_path) in the parent table of a set that describes the path to where that customer's files reside. If it's a form based on a standalone table, table.current(1) below would become just table.current().

              Your script would contain code something like

              Code:
              dim cust_files_path as c
              dim cust_files as c
              cust_files_path = alltrim(table.current(1).cust_path)
              cust_files = ui_get_files_multiple("SELECT FILES",Cust_Files_Path,"*.*")
              This would put the selected files into a list called cust_files which you can then process using a *For_Each() statement, by putting the list values into an array or simply processing the list line by line using the Word() function.

              You could also be getting the path in a different way but you'll need to give us more information.

              Anyway, save the script as "GetFiles" or something like that and enter Script_play(\"GetFiles\" ) into the Get_Watch function.
              Finian

              Comment


                #8
                Re: watch for file

                Hi

                Thanks so much for your efforts allready. I will try to explain my wishes a bit better.

                I want to store in program files a folder called customers and in that folder sub-folders for all the different customers.
                From the form of a specific customer, I would like to be able to see the files containing the folder, belonging to that customer.

                So your describtion sounds good Finian, Though i dont know how to extract the path to the particular folder of that customer. Can I assume table current() would work when cust_path is C:\\program files\customer\customerX ??

                Thanks

                Evert

                Comment


                  #9
                  Re: watch for file

                  Where are the application files stored? Are all the files (tables and sets etc) in the same folder?

                  <<I want to store in program files a folder called customers and in that folder sub-folders for all the different customers. From the form of a specific customer, I would like to be able to see the files containing the folder, belonging to that customer.>>

                  How are the customer sub-folders named?

                  <<Though i dont know how to extract the path to the particular folder of that customer.>>
                  See question above

                  <<Can I assume table current() would work when cust_path is C:\\program files\customer\customerX ??>>
                  No, you can't make that assumption. What sort of files are stored in the individual customers' folders?
                  Finian

                  Comment


                    #10
                    Re: watch for file

                    Hi Finian,

                    <<Where are the application files stored? Are all the files (tables and sets etc) in the same folder?

                    No, in a complete different folder, virtually not being connected to the folder where I store the actual tables and sets.

                    I would like to name those folders after their company name.

                    Most common files I would like to reveal in the customer forms are .doc, .pdf, .sff and .xls files.

                    Thanks for your help!

                    Evert

                    Comment


                      #11
                      Re: watch for file

                      I'm afraid that you are still being a little sparing with your information. What you want to do is straightforward but without more specifics, it's very difficult to provide code that you could actually use in your application.

                      We have a pretty comprehensive document/file manager in our application It allows our users to create Word dcouments linked to a given patient as well as to link to any file that has already been saved in the system. It needs its own control table to store the linked information and a form to control the activities.

                      I've attached a screen shot of the file manager to help you understand what the code is doing.

                      Code:
                      topparent:name.activate()
                      dim global your_name as c;dim global app_path as c
                      userdefaults = app_path + "users" + chr(92) + trim(your_name) + Chr(92) + "app_user_defaults"
                      tu = table.open(userdefaults,file_rw_shared)
                      def_doc_path = trim(tu.docpath)
                      if def_doc_path = "" then		'no path has been set, set it automatically
                      def_doc_path = app_path + "users" + chr(92) + trim(your_name) + Chr(92)
                      msg_text = "The default document path for user " + alltrim(your_name) + " will be set to"
                      msg_text = msg_text + Crlf(2) + def_doc_path
                      msg_text = msg_text + Crlf(2) + "This can be changed in the \"Other\" menu, \"Configure User Options\"."
                      ui_msg_box("SET DEFAULT USER DOCUMENT PATH",msg_text,ui_attention_symbol)
                      tu.order("")
                      tu.fetch_first()
                      tu.change_begin()
                      tu.docpath = def_doc_path
                      tu.change_end(.T.)
                      end if
                      tu.close()
                      dim pid as c
                      pid = topparent:id.text
                      TopParent:PatFilesSub.new_record()
                      TopParent:PatFilesSub:id.text=pid
                      TopParent:PatFilesSub:savedate.value=date()
                      TopParent:PatFilesSub:user.text=your_name
                      filename = ui_get_file("Retrieve From:","All files (*.*)",def_doc_path,"X")
                      if filename = "" then
                      topparent.cancel()
                      end
                      end if
                      	
                      topParent:PatFilesSub:filename.text=filename
                      topParent:PatFilesSub:Filename.refresh()
                      topParent:PatFilesSub:description.activate()
                      END
                      Obviously this code will only work in my application. However, if you study it, you will see that the first part is just setting up a default path (def_doc_path) for the ui_get_file function to use toward the end of the code. App_path in our application is always the path to the main application folder in which there are various sub-folders used for specific purposes. For example, every user and machine using the app has a unique sub-folder.

                      To manage folders you need to look at the Dir_Create() and related functions. You also need to understand simple path "arithmetic" using functions like A5.Get_Path() and related functions. With these it's easy to manage folder creation and files management by concatenating paths and variables. In your case you need to get your customer name into a variable and use that to create a folder name.

                      In any event, the result of the above code is to create a record in a table that stores a full path/file name to a given file. This record is linked to the patient by the patient id and can be opened/retrieved by double clicking on the record in the browse. The dclick code uses the sys_open() function to open the appropriate application for the file. So if the suffix is ".pdf" it will open Acrobat, etc.
                      Finian

                      Comment

                      Working...
                      X