Alpha DevCon 2018
Results 1 to 28 of 28

Thread: Capturing PDF File Location Into a Character Field

  1. #1
    Member
    Real Name
    Bob M
    Join Date
    Dec 2001
    Posts
    540

    Default Capturing PDF File Location Into a Character Field

    Using A5-V10.5 on Windows 8 machine.

    I am able to find a pdf file location using a dialog box and the capture a non-Alpha File action Script feature.

    However, I want to save/store that pdf location and name in a character field, so in the future, I can click the field and open the file at a later date.

    There is a form in my database that includes a one-to-many link to a variety of pdf documents associated with a person's unique id. Hence it would be stored in a one to many browse field on the form. I use a button to call the XDialog Box.

    I know very little Xbasic and am comfortable with Action Scripting and do a great job of cut and paste when given the correct code!

    Thanks, in advance, for the help.

  2. #2
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,105

    Default Re: Capturing PDF File Location Into a Character Field

    The answer depends on the backend you're using (dbf or some version of sql).
    The most important thing, no matter what your backend is, would be that the character field
    must be large enough to contain the entire filename.

  3. #3
    Member
    Real Name
    Bob M
    Join Date
    Dec 2001
    Posts
    540

    Default Re: Capturing PDF File Location Into a Character Field

    the character field could easily be 75 or more, up to the max of 255. I doubt any filename + path would be more than 100 characters.

  4. #4
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,105

    Default Re: Capturing PDF File Location Into a Character Field

    is your backend dbf or sql (mssql, MySQL, MariaDB) ?

  5. #5
    Member
    Real Name
    Bob M
    Join Date
    Dec 2001
    Posts
    540

    Default Re: Capturing PDF File Location Into a Character Field

    By backend, are you referring to where the files reside on the computer? If so, files are on One Drive in specific folders related to unique customers and already in pdf format. I can open them from A5 but need help to link to them on One Drive so I can view from my CMS.

    I currently have a vendor provided (at a hefty cost) CMS package where I upload the files from that drive. I am creating my own CMS with A5 and want to preserve all the files as related to specific customers.

  6. #6
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,105

    Default Re: Capturing PDF File Location Into a Character Field

    are you using Alpha's DBF tables, or are you using some type of sql?

    What does your connection string look like ?

  7. #7
    Member
    Real Name
    Bob M
    Join Date
    Dec 2001
    Posts
    540

    Default Re: Capturing PDF File Location Into a Character Field

    Alpha DBF tables to store the link as well as find the files.

    Connection string? That is a term I am not familiar with.

  8. #8
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,108

    Default Re: Capturing PDF File Location Into a Character Field

    You are using the action script element Prompt for a filename? Do you want the result of that prompt stored in a new record in the browse or as a change to an existing record? This should do either.

    theset.zip
    Last edited by Stan Mathews; 05-12-2018 at 09:25 AM.
    There can be only one.

  9. #9
    Member
    Real Name
    Bob M
    Join Date
    Dec 2001
    Posts
    540

    Default Re: Capturing PDF File Location Into a Character Field

    Stan, the record will be/is always pre-existing. And each parent level record will have anywhere from 1- 100 or more pdf files in the appropriate field (many files per one parent record).

  10. #10
    Member
    Real Name
    Bob M
    Join Date
    Dec 2001
    Posts
    540

    Default Re: Capturing PDF File Location Into a Character Field

    Stan,

    After I unzip, where should I place the appropriate cdx file? Which one does what?

    Thanks

  11. #11
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,108

    Default Re: Capturing PDF File Location Into a Character Field

    Don't know what went wrong with the zip creation. Trying again.


    theset.zip

    Should have two tables and a set definition.
    There can be only one.

  12. #12
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,108

    Default Re: Capturing PDF File Location Into a Character Field

    Added Action script versions of the button scripts.

    theset.zip
    There can be only one.

  13. #13
    Member
    Real Name
    Bob M
    Join Date
    Dec 2001
    Posts
    540

    Default Re: Capturing PDF File Location Into a Character Field

    STAN,

    So sorry for the delay in responding. My wife's dad passed away last week and we have been in NC and dealing with this. I am finally back to sitting in front of a computer and trying to catch up.

    I imported your example into my database and I think I can see what you have done. Your example is what I want to do, find the pdf file, upload the location (not the file itself) into a database and finally, I want to be able to recall the file from its location for viewing or emailing purposes. I found your code for the location and its DB placement. But I am unable to actually open the file, even using the Action Script open non Alpha file. Is there something I am not seeing in your example.

    Isuppose I can upload my own DB, if that would help.

    Again, I am sorry for the delay.

    Thanks

  14. #14
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,108

    Default Re: Capturing PDF File Location Into a Character Field

    I misunderstood. I though you indicated that you could open them.

    The action script for a button on the form in my example to open the pdf named in the currently selected row of the browse is shown in the attached screenshot.

    Image 24.png
    There can be only one.

  15. #15
    Member
    Real Name
    Bob M
    Join Date
    Dec 2001
    Posts
    540

    Default Re: Capturing PDF File Location Into a Character Field

    Stan,

    I can open the file in it's "natural" location but never could get far enough to test opening it in my DB.

    If I create an event on the field holding the file name using your above image, that would work??? Or should I create a browse button?

  16. #16
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,108

    Default Re: Capturing PDF File Location Into a Character Field

    You don't create events. You code the ones that are available.

    If, as in my example, your pdf drive-path-filename-ext value is in a browse field you could, instead of the button on the form, code the onrowdblclick event with the same action script.
    There are no other suitable events for browses. The browse button will also work but I am not sure you could use action scripting. You might have to capture the xbasic of the action and put that in the browse button code.
    There can be only one.

  17. #17
    Member
    Real Name
    Bob M
    Join Date
    Dec 2001
    Posts
    540

    Post Re: Capturing PDF File Location Into a Character Field

    Stan

    Using your example, I created a button on a form with the following code

    contact_quotes = ui_get_file("File search","PDF(*.pdf)","C:\*.pdf","X")
    if file.exists(contact_quotes)
    tbl = table.current(2)
    tbl.enter_begin()
    tbl.pdffile = contact_quotes
    tbl.enter_end()
    end if
    parentform.Resynch()

    I changed the name of the table (child table in a set) to the name of my child table.

    The code opens file explorer and lets me find a directory and desired file. When I select the file to proceed, I get the following error

    I get this error message

    [/ATTACH]=[CONFIG]44890[/ATTACH]
    Attached Images Attached Images

  18. #18
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,108

    Default Re: Capturing PDF File Location Into a Character Field

    Is the table containing the pdf file location the first child listed as seen when viewing the set structure? If not you need to adjust the 2 in tbl = table.current(2) to be the same as the numeric position. IOW,

    parent is 1
    first child is 2
    second child is 3
    etc

    It may be less confusing to use

    Code:
    rslt  = ui_get_file("File search","PDF(*.pdf)","C:\*.pdf","X")
    if file.exists(rslt)
    	tbl = table.get("chld") 'substitute your table name where the pdf location field exists for chld, keep the quotes
    	tbl.enter_begin()
    	tbl.pdffile = rslt
    	tbl.enter_end()
    end if
    parentform.Resynch()
    There can be only one.

  19. #19
    Member
    Real Name
    Bob M
    Join Date
    Dec 2001
    Posts
    540

    Default Re: Capturing PDF File Location Into a Character Field

    this is a single set in the DB with multiple tables as child tables. All or related to either a customer unique ID number or a specific policy number

    If I read you correctly, I should count child tables down in the set until I get to contact_quotes and that number should replace the number (2). If I do the same thing but for a separate table with different type of documents then use the same codfe but once again count the child tables down from parent.

  20. #20
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,108

    Default Re: Capturing PDF File Location Into a Character Field

    Correct except count all tables. I amended my original answer to explain.
    There can be only one.

  21. #21
    Member
    Real Name
    Bob M
    Join Date
    Dec 2001
    Posts
    540

    Default Re: Capturing PDF File Location Into a Character Field

    where in the count is the child of a child? This particular table is #6 in child or #7 counting the child of a child?

  22. #22
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,108

    Default Re: Capturing PDF File Location Into a Character Field

    Vertical position as you look down the list, doesn't matter if it is off to the right.

    parent is 1
    first child is 2
    if there is a grandchild linked to first child it would be 2
    if not second child is 3
    etc.

    Also note tbl.pdffile = contact_quotes

    pdffile is the fieldname containing the pdf location in my sample. If your field name is different you have to change that in the script.

    Image 1.png
    Last edited by Stan Mathews; 05-22-2018 at 05:04 PM.
    There can be only one.

  23. #23
    Member
    Real Name
    Bob M
    Join Date
    Dec 2001
    Posts
    540

    Default Re: Capturing PDF File Location Into a Character Field

    This is, so far, the set structure

    setstructure.JPG

  24. #24
    Member
    Real Name
    Bob M
    Join Date
    Dec 2001
    Posts
    540

    Default Re: Capturing PDF File Location Into a Character Field

    I will change to the field title and see what happens

  25. #25
    Member
    Real Name
    Bob M
    Join Date
    Dec 2001
    Posts
    540

    Default Re: Capturing PDF File Location Into a Character Field

    I must be getting closer!

    Error Message changed

    ErrorMsg-2.JPG

  26. #26
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,108

    Default Re: Capturing PDF File Location Into a Character Field

    What is the current script?

    I will change to the field title and see what happens
    Not the field title in the browse. Use the actual field name.
    There can be only one.

  27. #27
    Member
    Real Name
    Bob M
    Join Date
    Dec 2001
    Posts
    540

    Default Re: Capturing PDF File Location Into a Character Field

    Stan,

    I got it!!!

    At least the add a new record part.. Now I need to go back with your buttons for adding to an existing record, which will coe into play as much as anything.

  28. #28
    Member
    Real Name
    Bob M
    Join Date
    Dec 2001
    Posts
    540

    Default Re: Capturing PDF File Location Into a Character Field

    Stan,

    I got the view the specific file resolved. I used your code as given in the image above, and put it on a specific button to be used for viewing the specific file. So far it works on one record but now, I need to test it some more with other records.

    Thanks for all your help.

Similar Threads

  1. Export a character field containing Line-Feed to a .CSV file
    By Farzadalpa in forum Windows Desktop Applications
    Replies: 10
    Last Post: 03-04-2016, 01:41 PM
  2. Easy way to display PDF file in web browser per file location listed in grid
    By clankford in forum Mobile & Browser Applications
    Replies: 4
    Last Post: 10-26-2015, 06:26 AM
  3. Getting the folder location on file upload and file download javascript
    By acceptthis in forum Application Server Version 11 - Web/Browser Applications
    Replies: 3
    Last Post: 03-09-2013, 06:00 PM
  4. Capturing the newly create file name after file.watch_create() trigger.
    By bergmd in forum Alpha Five Version 10 - Desktop Applications
    Replies: 2
    Last Post: 05-25-2011, 02:25 PM
  5. Use character field to reference image file
    By Howard G. Cornett in forum Alpha Five Version 6
    Replies: 3
    Last Post: 08-01-2005, 07:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •