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

Populating a File Select field automatically

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

  • Populating a File Select field automatically

    Another thing I have never got working
    Situation;

    Documents are saved to a specific folder.
    Each document has a unique identifier - say - 123a, 123b, 123c, 124a, 124,b, 124c - the a,b,c, identify variations in the document

    In my table I have records with the PK as 123, or 124 for example. They are unique.
    The table has 3 fields which will containing the a,b,c
    The form has a File Select field which I would prefer to be populated with the file reference automatically to avoid errors, so;

    Record 123 has 123a, 123b, 123c inserted into the appropriate field
    Record 124 has 124a, 124b, 124c inserted into the appropriate field

    Result should look something like this;

    Record;

    PK = 123
    a value = c:\my folder\123a.pdf
    b value = c:\my folder\123b.pdf
    c value = c:\my folder\123c.pdf

    Question. How to insert file paths into a table based on matching key data, and also get Alpha to refresh the PDF Viewer and display the PDF once uploaded?

    All help appreciated.
    Ted Giles
    Example Consulting - UK
    .

    sigpichttp://ec12.example-software.com//
    See our site for Alpha Support, Conversion and Upgrade.

  • #2
    Re: Populating a File Select field automatically

    You've lost me with the reference to inserting the file paths and uploading and the PDF viewer thrown in at the end.

    The path to each "a" pdf is

    "c:\my folder" + alltrim(str(fieldname_holding_pk_a_value))++".pdf"


    the "b"'s

    "c:\my folder" + alltrim(str(fieldname_holding_pk_b_value))++".pdf"

    the "c"'s

    "c:\my folder" + alltrim(str(fieldname_holding_pk_c_value))++".pdf"

    Re-reading your post, possibly you want to examine the contents of "my folder" and populate the corresponding fields in the table for each record if a, b, and c pdf documents are found?

    If so, something like this should work. (example with my table and directory)

    Code:
    'get pointer to destination table
    tbl = table.open("atest")
    tbl.order("id") 'pk field is "id"
    'get a list of pdf files in the directory
    lst = filefind.get("P:\executive\Mpurch\Archive\cur_mkts\*.pdf",FILE_FIND_NORMAL,"PN")
    'process each path\filename
    for each foo in lst
    	'find the pk value in the path\filename
    	str = extract_string(foo.value,"guide ",".pdf")
    	' if the pk is in the destination table
    	if tbl.fetch_find(str) > 0
    		'write the path\filename to the where field
    		tbl.change_begin()
    		tbl.where = foo.value
    		tbl.change_end()
    	end if
    next
    tbl.close()
    c:\my folder\123a.pdf
    For ease of use it would make sense to me to use

    lst = filefind.get("c:\my folder\*a.pdf",FILE_FIND_NORMAL,"PN")
    lst = filefind.get("c:\my folder\*b.pdf",FILE_FIND_NORMAL,"PN")
    lst = filefind.get("c:\my folder\*c.pdf",FILE_FIND_NORMAL,"PN")

    and make three passes.

    Your pk extraction would probably be

    Code:
    str = extract_string(foo.value,"r\\","a.pdf")
    str = extract_string(foo.value,"r\\","b.pdf")
    str = extract_string(foo.value,"r\\","c.pdf")
    Last edited by Stan Mathews; 06-12-2018, 09:11 AM.
    There can be only one.

    Comment


    • #3
      Re: Populating a File Select field automatically

      Thanks Stan, I had initially approached it in a different way but it didn't seem to work as I intended.
      What I tried was;

      Set a default value in the Rules for the field with the PDF location, because I know what that is
      Example;

      For the a field I captured the pk as a variable (123) then the default is c:/my folder/variable+a.pdf
      for the other fields it would be c:/my folder/variable+b.pdf and c:/my folder/variable+c.pdf

      My assumption was that if the c:/my folder/variable+a.pdf existed, then it would be possible to use that as the trigger for the PDF Viewer.
      It appears OK in field as a default, but the Viewer doesn't fire.

      I will see if I can get my head around your code, thanks for the quick response.
      Ted Giles
      Example Consulting - UK
      .

      sigpichttp://ec12.example-software.com//
      See our site for Alpha Support, Conversion and Upgrade.

      Comment


      • #4
        Re: Populating a File Select field automatically

        Just to be clear about running three passes, I meant something like...

        Code:
        'get pointer to destination table
        tbl = table.open("your_table_name",FILE_RW_EXCLUSIVE)
        tbl.order("id") 'pk field is "id"
        tbl.batch_begin()
        'get a list of pdf files in the directory
        lst = filefind.get("c:\my folder\*a.pdf",FILE_FIND_NORMAL,"PN")
        'process each path\filename
        for each foo in lst
        	'find the pk value in the path\filename
        	str = extract_string(foo.value,"r\\","a.pdf")
        	' if the pk is in the destination table
        	if tbl.fetch_find(str) > 0
        		'write the path\filename to the where field
        		tbl.change_begin()
        		tbl.pdf_a_field = foo.value
        		tbl.change_end()
        	end if
        next
        lst = filefind.get("c:\my folder\*b.pdf",FILE_FIND_NORMAL,"PN")
        'process each path\filename
        for each foo in lst
        	'find the pk value in the path\filename
        	str = extract_string(foo.value,"r\\","b.pdf")
        	' if the pk is in the destination table
        	if tbl.fetch_find(str) > 0
        		'write the path\filename to the where field
        		tbl.change_begin()
        		tbl.pdf_b_field = foo.value
        		tbl.change_end()
        	end if
        next
        lst = filefind.get("c:\my folder\*c.pdf",FILE_FIND_NORMAL,"PN")
        'process each path\filename
        for each foo in lst
        	'find the pk value in the path\filename
        	str = extract_string(foo.value,"r\\","c.pdf")
        	' if the pk is in the destination table
        	if tbl.fetch_find(str) > 0
        		'write the path\filename to the where field
        		tbl.change_begin()
        		tbl.pdf_c_field = foo.value
        		tbl.change_end()
        	end if
        next
        tbl.batch_end()
        tbl.close()
        There can be only one.

        Comment


        • #5
          Re: Populating a File Select field automatically

          OK, I am learning stuff Stan, thanks for helping the hard of thinking like me.

          Last soppy question (maybe).
          Can I interrogate the PDF Viewer (PDFViewer1) etc to see if there is any actual data present?
          Apparently there is an option for T or F but I cannot get the syntax correct in a CO.
          Ted Giles
          Example Consulting - UK
          .

          sigpichttp://ec12.example-software.com//
          See our site for Alpha Support, Conversion and Upgrade.

          Comment


          • #6
            Re: Populating a File Select field automatically

            I'm not understanding, sorry.

            If you want the pdf viewer supercontrol to display a pdf if a field contains a path to it, having already populated the field...

            specify the filename in the supercontrol like

            if(isnotblank("pdf_field"),alltrim(pdf_field),"")

            If you put the pdf viewer on a pane of a conditional object and want to display the pdf viewer if the pdf for a field exists the condition for the pane would be alltrim(pdf_field.value) > "" or file.exists(alltrim(pdf_field)) depending onwhether you want to test the field value or the actual existence of the file.
            There can be only one.

            Comment


            • #7
              Re: Populating a File Select field automatically

              Thanks. That's what I was after, Stan.
              Ted Giles
              Example Consulting - UK
              .

              sigpichttp://ec12.example-software.com//
              See our site for Alpha Support, Conversion and Upgrade.

              Comment


              • #8
                Re: Populating a File Select field automatically

                It was pointed out to me, graciously, that I had an extra + in these lines, now corrected. Also corrected the backslash in the path.

                Code:
                The path to each "a" pdf is 
                
                 "c:\my folder\\" + alltrim(str(fieldname_holding_pk_a_value))+".pdf"
                
                
                 the "b"'s
                
                 "c:\my folder\\" + alltrim(str(fieldname_holding_pk_b_value))+".pdf"
                
                 the "c"'s
                
                 "c:\my folder\\" + alltrim(str(fieldname_holding_pk_c_value))+".pdf"
                There can be only one.

                Comment


                • #9
                  Re: Populating a File Select field automatically

                  Most gentlemanly!
                  Thanks
                  Ted Giles
                  Example Consulting - UK
                  .

                  sigpichttp://ec12.example-software.com//
                  See our site for Alpha Support, Conversion and Upgrade.

                  Comment

                  Working...
                  X