Jump to content
Salesforce and other SMB Solutions are coming soon. ×

filepath for importing folder not the same as filepath format for send event


Maarten Witberg
 Share

Recommended Posts

Hi,

 

I ran into the following (8.0v2):

when you import a folder of image files, you can specify to import the filepath to a text field.

On a mac (10.3.9), this results in a filepath of the format

file://MyHarddisk/Users/kjoe/images/subfolder/PICT0112.JPG

 

now when storing this in a variable, and using that variable in the script step Send Event (Open document), there's an error message, the file can not be found.

 

Small wonder, because the filepath of the above format is not in the list of recognized formats for the open document event, it should be for instance:

filemac:/VolumeName/dirname/...

 

Now I suppose it's not too hard to replace the filepath by auto enter upon import, but I think this looks like a glitch unless I'm missing something.

I'm going to see if I can find out anything about this, but in the meantime I'd be indebted to anyone who can shed a light

 

kjoe

Link to comment
Share on other sites

Update:

The path format does work with "Open URL", but that's no use, it picks Preview for me as app (standard for the file type), I need the file to open in Photoshop or ultimately a program picked by the user.

Far as I can see, there's nothing in the Knowledge base on this except the above suggestion. (answer ID 539). I guess its auto enter time, it looks like they did this on purpose.

 

kjoe

Link to comment
Share on other sites

I don't know if it sheds any light, but there is more:

 

If you IMPORT a folder of PICTURES as a reference only, the path in the imported field is as you say:

file://

 

But if you define a calculation field (result is text) =

Containerfield

 

the result is in the format:

image:/

 

If you INSERT a single PICTURE as a reference, you get:

size:xx,yy

image:

imagemac:

 

If you INSERT a FILE, the result is:

file:

filemac:/

 

Take your pick.

Link to comment
Share on other sites

Hi Comment,

 

using path=containerfield (text result) suits me just fine as it is recognised in the Send Event. Beautiful :)

 

thanks

kjoe

Link to comment
Share on other sites

  • 5 months later...

I seem to be having issues with the suggestions on this thread can anyone see what I am doing wrong.

 

thanks,

Kari

 

I have done what you said here, but still when I make a "Send Event" it says the file is "".

 

I have 2 pictures on my desktop in a folder- just as a test. I have 5 fields- "Filepath" (text), "Filename" (text), "Thumbnail" (container), "image" (container)---and "Calculation" (text = image). I import the pictures using Import-folder function, and try and open the calculation field by doing a "Send event". I have tried changing calculation so that it is equal to every field and still the file says "the file "" can not be found..." am I doing something wrong?

 

Thanks for your time,

I will also post it on the forum in case you don't have time,

Kari moreno

Link to comment
Share on other sites

hi all,

 

i have had this problem, and it drove me up the wall! what the main cause of this is the idea of your "current working directory (CWD)". When FMP starts up, the CWD is where the FMP file is located in the system. BUT in you insert a picture, or what ever, into a container using the browser functionality, this will change your CWD to where ever you browsed to! the reason for this is so when you insert another picture it will automatically return you to the previously visted folder.

 

so when you use the "Send Event" functionality, FMP will start the process where you are using relative or absolute paths, BUT it will start the process in the CWD, which could be anywhere on the file system.

 

if you want robustness, then you need to use the Get(DocumentPath) type functions as they will always return the same path. The one mentioned above gives you, on windows, the absolute path to the "My documents" for the current user.

 

the way I solve this type of problem is by running a script at the start up which does a send event to a VBscript which creates a hidden folder in My documents which i then copy all the different files and what not i need in. if you want this vbscript, just ask and i will post.

 

cheers,

fronce

Link to comment
Share on other sites

ok so you need a folder at the same level as the FMP file is located with all your stuff in it.

 

does this forum allow html tags to be posted? i will give it ago, if it doesn't work i will re-post:

 

'get location of my documents

Set WshShell = WScript.CreateObject("WScript.Shell")

FolderName = "Your_Folder_Name"

FolderNewLocation = WshShell.ExpandEnvironmentStrings("%USERPROFILE%") &"\My Documents\Your_Folder_Name""

 

'create system object and get directory listing.

Set filesys = CreateObject("Scripting.FileSystemObject")

 

'check if hidden folder exists, if not create, copy contents and hide it.

If Not filesys.FolderExists(FolderNewLocation) Then

    'if folder does not exists, then copy it from the project directory and hide it.

    If filesys.FolderExists(FolderName) Then

        location = filesys.GetAbsolutePathName(FolderName)

        filesys.CopyFolder location, FolderNewLocation

 

        'this bit hide the folder, so if you don't want it hidden,

        'remove from here to the *****'s

        Set objFolder = filesys.GetFolder(FolderNewLocation)

        If objFolder.Attributes = objFolder.Attributes AND 2 Then

            objFolder.Attributes = objFolder.Attributes XOR 2

        End If

        '********

    End If

End If

 

 

cheers,

fronce

Link to comment
Share on other sites

nope it doens't! ignore the one above.

 

 

'get location of my documents

Set WshShell = WScript.CreateObject("WScript.Shell")

FolderName = "Your_Folder_Name"

FolderNewLocation = WshShell.ExpandEnvironmentStrings("%USERPROFILE%") &"\My Documents\Your_Folder_Name""

 

'create system object and get directory listing.

Set filesys = CreateObject("Scripting.FileSystemObject")

 

'check if hidden folder exists, if not create, copy contents and hide it.

If Not filesys.FolderExists(FolderNewLocation) Then

'if folder does not exists, then copy it from the project directory and hide it.

If filesys.FolderExists(FolderName) Then

location = filesys.GetAbsolutePathName(FolderName)

filesys.CopyFolder location, FolderNewLocation

 

'this bit hide the folder, so if you don't want it hidden,

'remove from here to the *****'s

Set objFolder = filesys.GetFolder(FolderNewLocation)

If objFolder.Attributes = objFolder.Attributes AND 2 Then

objFolder.Attributes = objFolder.Attributes XOR 2

End If

'********

End If

End If

 

cheers,

fronce

Link to comment
Share on other sites

Total newbee to FM (second time around from before Claris days actually) but I have a question relative to this.

8.5 Advanced (mac)

 

script InsertFile [Reference; poser_db::path_readme]

 

path_readme is defined as a container field.

 

Putting that field on my layout in form view I see a text icon which I can double click on and open the file. In reading the above and other threads I thought I was suppose to see the file path and then another file path after a paragraph return with the filemac:/ stuff.

 

Because I can see the path in a calculation field which returns

Macintosh HD/Applications/Poser 7/Runtime/Untitled9.txt

 

via this calculation which I hacked together from various threads.

 

Let ( [

text = RightValues ( GetAsText ( path_readme ) ; 1 ) ;

start = Position ( text ; "/" ; 1 ; 1 ) + 1 ;

end = Position ( text ; ¶ ; 1 ; 1 )

] ;

Middle ( text ; start ; end - start )

)

 

 

then I have another script that does not work and gives me a file not found error even if the above path is correct

 

Send Event ["TextEdit.app"; "avet"; "odoc"; "filemac:/" & poser_db::path_to_readme2]

 

A: are you supposed to see the icon of the doc in the container form view? If not what did I do wrong? (even a wild guess would help)

 

B: What is wrong with the rest of the stuff to the point I am getting a file not found error. Based on what I have read and the threads here I thought it would work.

 

Thanks a ton...

 

PS:

The project is to track Poser assets where people normally store their readme's inside the various sub folders inside the poser runtime directory and have several hundred of these scattered about which I am trying to link to via file reference on an asset by asset basis.

 

PS2: what did I do wrong so I see smiles in my code via firefox?

Link to comment
Share on other sites

hi grichter,

 

hang on, lets take a step back!

 

if you have a container field (your's called path_readme) with the file which you have inserted into it (say boobar.txt), then the field path_readme actually contains the file boobar.txt, not a reference to it. so if you now went and deleted boobar.txt, then you could still export the file as FMP would have a copy of it.

 

does that make sense? if you only want a reference to the file, then you would probably only need a Text field (note the probably).

 

cheers,

fronce

Link to comment
Share on other sites

Puzzled because the help docs say

 

 

Format

Insert File [Reference; <:field>; ""]

 

Options Store only a reference instructs FileMaker Pro to store only a link to a file in the container field instead of the entire file. This option may reduce the size of your FileMaker Pro file, but if you move or delete the file being referenced, FileMaker Pro won't be able to display it.

 

 

Based on what I am reading it should not have inserted the file, just a reference. Maybe I am confused by the wording link vs thinking I was going to get just file path from the root only and had only that to work with.

Link to comment
Share on other sites

Perhaps it is easier to use the script step

 

go to field [select/perform ; TheContainerField ]

 

as far as I tested, then it does not matter where the referenced file is stored.

By the way, I wonder if the VB script is any use to Karibarikix, whos profile says he's on mac.

Link to comment
Share on other sites

Yes it is. Perfect! Like I said still learning. Thanks a ton

 

Never wanted the icon of the local file to show on the form view. To complete the process would be design a conditional transparent button over a reporting field. isEmpty(container)= 1 button field says "load readme", IsEmpty(container)=0 field says "read readme"

Link to comment
Share on other sites

Minor cosmetic glitch I need help with

On the form view page. Field for container .100 x .100 (don't want to loose track of it, yet!) set to back. On top of it is calculation field no boarder fill in background color Case(IsEmpty(readme_file); "Load" & ¶ & "ReadMe"; "View" & ¶ & "Readme")

On top of that is a transparent button to a script

If container is empty then insert file

else show custom dialog

if (Get (lastMessageChoice) = 1 then select perform (ie:read the file)

Else if Get (lastMessageChoice) = 2 then replace field contents "" (clear the field)

Else if (Get (lastMessageChoice) = 3 insert file (IE we moved it so lets change the reference by replacing the file)

end if

 

The last part is my shot at a logical change function under a one button scheme

 

If you cancel out of the insert process the field boundary of the container shows up under all the filled field on top of it until you move your mouse off the button and click elsewhere. Barring making the container as tiny as possible. Is there a standard scheme used to hide field boundary of the container when you cancel the insert process other then sticking it a bottom corner of the layout. Again a newbee so I might have missed a setting somewhere and didn't realize it. Having that little black box appear is annoying and might confuse users of the eventual runtime solution.

 

FYI: Show field frames when active is unchecked for this layout.

 

TIA

Link to comment
Share on other sites

I'm not sure if the container field needs to be on the layout. You can test if your script works by deleting it. If it stops working, put the container on another layout and switch layouts in the script, using the "freeze window" script step to ensure the user does not see the "hidden" layout.

Link to comment
Share on other sites

Thanks and in my testing it did not work unless it was on the layout.

 

Smallest FM would allow me to make it was .014 x .014 which shows up just a hair bigger then a period. Which at that size it is not that bad compared to where I was an hour ago at .100 x .100. Problem is if I ungroup the 2 fields and button stack and shift things around..doh now where dd it go :)

 

My question was more of how do you hide or soften the active field boundary for future reference, because at .014 x .014 unless you know it is there, the small dot has now become sort of a none issue at this point of my design. But if I could have left it bigger the chance of me miss placing it goes away. It will be interesting if my testers notice the dot.

Link to comment
Share on other sites

Here are all the gory details. I would like anyone to tell me how to improve it. That is the only way I will get better.

 

I have a container field to store inserted object named readme_file Which is meant to be a text file located on the local users hard drive. I can find nothing or no way to code the script in such a way that it only allows a .txt, .doc, or even a .pdf file to be linked vs the user making reference to a graphics file, like a .jpg or a .png, etc. At this point I am not 100 percent sure I need to even consider that restriction, if it was even possible, in this solution I am creating. Since it is only a reference to a local file, it is not like they are going to fill the db up with huge graphics files if there were embedded.

 

calculation field named readme_button_label to show status of the container readme_file

Calculation of the readme_button_label field is

Case(IsEmpty(readme_file); "Link to" & ¶ & "ReadMe" & ¶ & "File"; "View" & ¶ & "ReadMe" & ¶ & "File")

 

 

On the layout in form view, the container field readme_file is set to .014" wide by .014" high which is the smallest FM will allow me to make it. (which happens to be the same as 1 pixel wide by 1 pixel high if you change to pixel measurements, which makes sense from an FM operational point of view). I don't want the user to see this field. But the field has to be on the layout for the insert to work, my testing is telling me.

 

On top of the container field is the calculation field readme_button_label Which will change the text it displays in the button from "Link to ReadMe File" if the container is empty to "View ReadMe File" if the container is more then empty (granted it is formatted in the calculation field to be 3 lines tall, formatted center and middle vs one continuous line as typed here), IE: Has there been a readme.txt file linked to the container field or not? If so you know so and can View it.

 

On top of that is a transparent button with no text and just a border, linked to a perform script. That script reads:

 

If[isEmpty ( Poser_db::readme_file)]

Insert Flle [Reference; Poser_db::Readme_file]

Else

Show Custom Dialog ["Readme File Instructions";.....(I won't bore you we a bunch of details of what I typed there but it explains the following)

The default button or 1 states "Read", Button 2 states "Clear" and Button 3 states "Change"

 

If [Get ( LastMessageChoice ) = 1

Go to Field [select/perform; Poser::readme_file]

Else if [Get ( LastMessageChoice ) = 2

Replace Field Contents [No dialog; Poser_db::readme_file; ""]

Else if [Get ( LastMessageChoice ) = 3

Insert File [Reference; Poser_db::readme_file]

End if

End if

 

Caveats:

I chose to use Else in the outside if, end if structure vs Else if not isEmpty to make sure I landed somewhere in the event of an error.

The 3 buttons of the dialog box are designed to:

The default Button or 1; Read the file (hit return)

Button 2; remove or empty the container readme_file

Button 3; change the readme file, cause I selected the wrong one or moved it elsewhere in the directory structure.

 

I felt I needed to give the user these options or the solution was not too user friendly and allowed no corrections for mistakes and or the relocating of the readme file.

 

In the late 1970's up until the early 1990's I programed in Business Basic, sitting on top of a unix shell on a MAI Basic 4 box, which became an IBM RISC Box over time. IF was a common programming verb, CASE was not available that I can remember. I assume I could change the outside structure from an IF, END IF to a CASE like the calculation field (maybe toss in a local variable) to catch the status of the readme_file field vs relying on it falling into the ELSE statement. But my mind doesn't think in CASE. Plus I think it is easier to read-debug as written.

 

So have at it and tell me if I made any glaring errors that could or world crop up at a latter date once the runtime is placed in other peoples hands who don't know the under lying code structure and what to expect.

 

TIA

Link to comment
Share on other sites

You've got a script that works, but I suggest a few tweaks.

1. you need to reckon with user abort. You have got no "cancel" button. If the user mistakenly clicks the button he is forced to make a choice. I am not sure why you have inserted the "clear" button. If there's only a referenced file, there is hardly any burden on the database even if the link is obsolete. Since you're not showing the container, why bother? Use the third button as a cancel button...

Also, if the user clicks "change", if he cancels the insert dialog, he'll get a confusing message if he wants to continue the script or cancel it. Use the "set error capture [on]" script step at the beginning. this will abort the script if no further error trapping is coded after a dialog like "insert file".

2. you can put the container on a separate layout to make it easier for you to find and to hide it from the user.

 

so the script would run (your "clear" procedure still in place):

 

[b]set error capture [on]
freeze window
go to layout [hidden_container][/b]
If [ isempty [TheContainer ]
Insert file [reference ; TheContainer ]
Else
show custom dialog[blah;blah; #1=read 2=clear 3=change]
if [get (lastmessagechoice) =1 ]
  go to field [select/perform ; "theContainer" ]
else if [get (lastmessagechoice) =2 ]
  set field [TheContainer; ""]
else
  Insert file [reference ; TheContainer ]
end if
end if
[b]Commit records / requests
go to layout [ original layout ][/b]

 

 

For the button, you can also decide to make the calc field a button without bothering with the transparent button. Or put the field on top of the button, lock it so when the user clicks, he will hit the button not the field. So you can give the button a color.

 

PS one last thing, if any user is allowed to clear or change the readme, won't another user be confused if he suddenly finds his file missing?

Link to comment
Share on other sites

You've got a script that works, but I suggest a few tweaks.

1. you need to reckon with user abort. You have got no "cancel" button. If the user mistakenly clicks the button he is forced to make a choice. I am not sure why you have inserted the "clear" button. If there's only a referenced file, there is hardly any burden on the database even if the link is obsolete.

 

Been working on the guts, can I get this to do what I want first, not the nuances, so very few of my scripts at this point have the user abort added. Will go back and clean them all up. Regarding the clear button the issue is the same as the cancel button. Lets assume the user clicked on the button and selected a readme by mistake. He has no way to clear the mistake if the readme does not exist or for example at a later date decides the readme isn't worth looking at anymore or in another example deletes the sub folder where the readme was by choice, and changes the classification of the record to reflect that (something I am considering adding as an option vs delete the record out right). This way they can turn off the flag ("View ReadMe File") If you have a thousand records, the typical user is not going to remember which record points to a bogus or worthless Readme. Going to have to rethink the concept over from the start and come up with a different type of flag mechanism. You are absolutely right, just stepped right over the error code stuff, doh.

 

Will give the separate layout listed below a whirl. Rather dumb I used the replace field vs set field, and you never mentioned that mistake :)

-------

 

Since you're not showing the container, why bother? Use the third button as a cancel button...

Also, if the user clicks "change", if he cancels the insert dialog, he'll get a confusing message if he wants to continue the script or cancel it. Use the "set error capture [on]" script step at the beginning. this will abort the script if no further error trapping is coded after a dialog like "insert file".

2. you can put the container on a separate layout to make it easier for you to find and to hide it from the user.

 

so the script would run (your "clear" procedure still in place):

 

[b]set error capture [on]
freeze window
go to layout [hidden_container][/b]
If [ isempty [TheContainer ]
Insert file [reference ; TheContainer ]
Else
show custom dialog[blah;blah; #1=read 2=clear 3=change]
if [get (lastmessagechoice) =1 ]
  go to field [select/perform ; "theContainer" ]
else if [get (lastmessagechoice) =2 ]
  set field [TheContainer; ""]
else
  Insert file [reference ; TheContainer ]
end if
end if
[b]Commit records / requests
go to layout [ original layout ][/b]

 

 

For the button, you can also decide to make the calc field a button without bothering with the transparent button. Or put the field on top of the button, lock it so when the user clicks, he will hit the button not the field. So you can give the button a color.

 

PS one last thing, if any user is allowed to clear or change the readme, won't another user be confused if he suddenly finds his file missing?

 

The target solution is to eventually bundle and distribute as a runtime to be used by single users. Under that environment I am operating under the concept any user does not apply.

 

Thanks a ton for taking the time to look my mess over and make critical suggestions. Now need to go back and rethink this section of my code over from top to bottom regarding how I need to flag empty, full or disregard.

 

One last newbee technical question. I can't seem to find any reference in the docs or any of the books I have regarding the concept write once use many places. How much of a hit do you take using my old programming lingo perform a "call" or in the case of FM perform a script within a script burden the performance. A lot or a little?

Link to comment
Share on other sites

or in another example deletes the sub folder where the readme was by choice

that's tricky. managing files from within filemaker is always dependent on the great big gaping hole that is called Finder or Windows - unless the folder where the readmes sit is protected by powerful amulets and spells. (such as read-write permission). I'm not really experienced with that. I started this thread so many months ago because I wanted a better management of our digital photo server, but I have since abandoned this for a couple of reasons, most notably complete user indifference to the subject.

 

you never mentioned that mistake

completely overlooked it.

 

regarding the concept write once use many places. How much of a hit do you take using my old programming lingo perform a "call" or in the case of FM perform a script within a script burden the performance. A lot or a little?

 

as far as I can tell, calling a subscript instead of adding the same code in the main script makes no performance difference. It's a timesaver to the developer - if he takes care to create subscripts that can be applied throughout his solution.

performance hits in scripts are - working on large found sets, looping scripts, working with sorted sets. that kind of thing. my knowledge there is patchy I must admit.

 

maarten

Link to comment
Share on other sites

that's tricky. managing files from within filemaker is always dependent on the great big gaping hole that is called Finder or Windows - unless the folder where the readmes sit is protected by powerful amulets and spells. (such as read-write permission). I'm not really experienced with that. I started this thread so many months ago because I wanted a better management of our digital photo server, but I have since abandoned this for a couple of reasons, most notably complete user indifference to the subject.

 

If you change to set error off, and the file you are looking for has been deleted, moved, etc (It ain't where it's suppose to be) FM throws up a dialog box "file (name) not found and is needed to complete this operation and if you cancel you fall into the hidden_container layout from your example. (used as a test only)

 

If you leave set error capture on and it can't find the file the user will never know as nothing happens. It just falls back onto the original layout page as expected.

 

So using an example from the book Filemaker 8 Functions and Scripts Desk Reference I turned set error capture back on (where I want it all the time) and added some code that returns error = 100 or File is missing.

 

So adding

If [Get (LastError) = 100]

toss up a custom dialog box that says...

I can't find the file, it's missing. You idiot why did you move or delete the file! Then perform script "slap user on the side of the head" (have to put in a feature request for the latter to FM)

end if

 

the issue of the missing file is handled.

 

Yes sometimes users are more painful then getting a root canal!!!!!

 

Regrading adding layouts like the hidden container one in your example or using subscripts that would make the coding ten times easier, I have been overly lean to a fault thinking I will drag performance down dramatically. So far about 105 scripts and about 20 layouts and maybe 3/4 of the way to getting the main guts working like I hope.

Link to comment
Share on other sites

good job adding the error=100 capture.

 

In many cases, after a script step that can generate an error, only one specific error can occur. Then you can fall back to using

"Get(LastErrror)0"

Saves time looking up and down the list to find the right number smiley_cool

Link to comment
Share on other sites

This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

Terms of Use