Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4764 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Can someone point me as to why this import isn't working:

  • Set Variable [ $importdir; Value:Moo_DialogFolder ]
  • Send Event [ open document/application; "cmd /c cd " & $importdir & "&&" & "dir /b > filelist.txt" ] [ Bring application to foreground ]
  • Pause/Resume Script [ Duration (seconds): 3 ]
  • Import Records [ Source: “filewin:/$importdir & filelist.txt”; Target: “IMAGES”; Method: Add; Character Set: “Windows ANSI”; Field Mapping: Source field 1 import to IMAGES::IMAGE1 ]

The first step opens a dialog box to select a folder, saves it as $importdir variable. Works fine

Second step sends windows an event to open a cmd prompt and create a file in the save folder designated by $importdir. Works fine.

I now want the import dialog to open an import dialog with the same file created. I figured using the same $importdir variable and the filelist.txt it would work but I always get an error know matter how I format it.

I tried:

filewin:/$importdir & filelist.txt

filewin:$importdir & filelist.txt

filewin:$importdir & "filelist.txt"

Thank you

Posted

Try it this way:

Set Variable [ $importdir; Value:Moo_DialogFolder ]

...

Set Variable [ $path; Value: "filewin:/" & $importdir & "filelist.txt" ]

Import Records [ Source: “$path”; Target: ... ]

This may need a tweak, depending on the exact format of the folder path returned in the first step.

Posted

This is path returned by the variable $importpath during after a folder is selected:

C:UsersownerDesktopedit201476

I'm getting an error dialog:

"The file "C:UsersownerDesktopedit201476filelist.txt" could not be found and is required to complete this operation."

The file does exist and was created successfully. Hitting ok on the dialog box allows a continue, where selecting the file manually completes the import.

Posted (edited)

Pathing is a confusing issue. You list cross platform. Could that be why it is failing? Upon which OS are tests performed? Here are some considerations when addressing xplat:

Windows use backslashes in file names, Macs use forward slashes. You can normalize to use backslashes with something similar to: Substitute ( $$path ; [ "/" ; "" ] )

But even on Windows, if you issue Get(DesktopPath), it lists with forward slashes. Both platforms start with slash - you do not have one on your examples and if you list a full path (and not just relative) then you must list the FULL path including volume and they are different on each OS.

Your data source on the Import script should list both each on separate line as:

filewin:$filepath

filemac:$filepath

You can check for system platform upon load. Be sure to account for PowerPC Macs:

Case ( Abs ( Get ( SystemPlatform ) ) = 1 ; .... put path result (I corrected this line ... you do not need volumes preceding the string unless using plugins but you should still test the platform and create the proper path by the results).

So final paths should end up looking similar to:

Windows: /C:/Documents and Settings/Owner/Desktop/edit/201476/filelist.txt

Mac: /Macintosh HD/Users/User/Desktop/edit/201476/filelist.txt

Edited by LaRetta
Posted

Pathing is a confusing issue. You list cross platform. Could that be why it is failing? Upon which OS are tests performed? Here are some considerations when addressing xplat:

Windows use backslashes in file names, Macs use forward slashes. You can normalize to use backslashes with something similar to: Substitute ( $$path ; [ "/" ; "" ] )

But even on Windows, if you issue Get(DesktopPath), it lists with forward slashes. Both platforms start with slash - you do not have one on your examples and if you list a full path (and not just relative) then you must list the FULL path including volume and they are different on each OS.

Your data source on the Import script should list both each on separate line as:

filewin:$filepath

filemac:$filepath

You can check for system platform upon load. Be sure to account for PowerPC Macs:

Case ( Abs ( Get ( SystemPlatform ) ) = 1 ; .... put path result (I corrected this line ... you do not need volumes preceding the string unless using plugins but you should still test the platform and create the proper path by the results).

So final paths should end up looking similar to:

Windows: /C:/Documents and Settings/Owner/Desktop/edit/201476/filelist.txt

Mac: /Macintosh HD/Users/User/Desktop/edit/201476/filelist.txt

Currently, for this project it's only on Windows. Thank you for the cross platform information though. I tried different variations of your suggestions and am still getting the same error. The funny thing is the error shows the correct path to the file, which exists. The 'Send Event' also works correctly using the same variable/path.

Posted (edited)

I do not know about MooPlug, never used it. But importing and paths in FileMaker are forward slash and it is only if you are working at the OS level or with plugins that you need to 'normalize' the slashes.

Using Send Event[] on Windows and importing on Windows, forward slashes are used for paths, just like on Mac. This is why my final example shows how paths should look to FM. I believe that you are showing an FM error on "C:UsersownerDesktopedit201476filelist.txt" because FM cannot understand the back slashes.

Your plugin may need that configuration so you may need to switch their direction before your final import. And I hope that, by providing OS differences, it hasn't confused the issue even further.

Edited by LaRetta
Posted

BTW, ScriptMaster needs 'Volumes' prepended on paths for Mac but FileMaker imports don't need it. MooPlug might be similar.

Which reminds me - I posted an identical situation here without plugin:

http://fmforums.com/...d-in-file-name/

You can take a look at the paths - it bypasses need for plugin which was part of their requirements.

Posted

BTW, ScriptMaster needs 'Volumes' prepended on paths for Mac but FileMaker imports don't need it. MooPlug might be similar.

Which reminds me - I posted an identical situation here without plugin:

http://fmforums.com/...d-in-file-name/

You can take a look at the paths - it bypasses need for plugin which was part of their requirements.

I'm taking a look at the Grabfiles example right now. I changed the path in your example to a folder on the desktop and received an error about not being able to create the file. Tried running FM as administrator and even designating a path within the user directory (such as Documents) and no go. Odd thing is the mooplug works elsewhere. I'm going to try the 360 plugin to see if returns a different result.

Posted

Doing this works: filewin:/Users/owner/Desktop/edit/201479/filelist.txt

but the '201479' is dynamic and changes.

How about a way to convert the '' slashes to '/' prior to import?

Posted

Odd thing is the mooplug works elsewhere. I'm going to try the 360 plugin to see if returns a different result.

I don't think that's the issue here. Your path for the Import Records[] step must be a valid Filemaker path, which is NOT the same as the OS path - see:

http://www.filemaker.com/11help/html/create_db.8.32.html#1030283

Posted

I was afraid I might have confused by mixing in OS and then plugin but that is exactly, I believe, why this confusion arose to begin with. No, it is not the plugins or VBScript, they are simply at different layers here than FM. I should have spotted it immediately when you said FM gave "c:... " error but I missed it because I work at OS level so much.

Doing this works: filewin:/Users/owner/Desktop/edit/201479/filelist.txt

but the '201479' is dynamic and changes.

Then further control and calculate your path by breaking it into pieces. If 201479 is part of a record (ClientID, invoice# etc) just store that in different variable and concatenate the variables into one final $fullpath. You need to give your plugin what it needs first and what it needs for both platforms to work on OS level. You can use Case() statements to test ... I started to show you using Case(Abs(Get(SystemPlatform... but I sidetracked myself onto something else.

How about a way to convert the '' slashes to '/' prior to import?

That is what the Substitute calculation is for. I might have confused you because the example showed how it would be used with an existing path when working at DOS or OS levels on windows (and with some plugins). So just reverse the slashes in the calc.

Posted

IIUC, 201479 is the name of the directory selected in the first step. IOW, the first step sets the $importdir variable to:

C:UsersownerDesktopedit201476

with or without the final slash.

Doing this works: filewin:/Users/owner/Desktop/edit/201479/filelist.txt

That doesn't seem right - I believe it should be:

filewin:/C:/Users/owner/Desktop/edit/201479/filelist.txt

Posted

IIUC, 201479 is the name of the directory selected in the first step. IOW, the first step sets the $importdir variable to:

C:UsersownerDesktopedit201476

with or without the final slash.

That's correct, there's hundreds of folders with various numbers.

That doesn't seem right - I believe it should be:

filewin:/C:/Users/owner/Desktop/edit/201479/filelist.txt

That's what I gathered from the link you posted. Oddly, it works both ways.

I was afraid I might have confused by mixing in OS and then plugin but that is exactly, I believe, why this confusion arose to begin with. No, it is not the plugins or VBScript, they are simply at different layers here than FM. I should have spotted it immediately when you said FM gave "c:... " error but I missed it because I work at OS level so much.

Doing this works: filewin:/Users/owner/Desktop/edit/201479/filelist.txt

but the '201479' is dynamic and changes.

Then further control and calculate your path by breaking it into pieces. If 201479 is part of a record (ClientID, invoice# etc) just store that in different variable and concatenate the variables into one final $fullpath.

I already do that, but after the fact. The number corresponds to a folder that is labeled with that number. There are hundreds of folders, each unique. After the filelist is imported, I pull the number out of the path and that is dropped into a field so the the imported items match. I can manually browse for the filelist.txt created after the sendevent creates it and import, but with hundreds of folders its tedious. Since each folder will have it's own filelist generated, it makes sense to use the $importdir to automatically import the filelist.

How about a way to convert the '' slashes to '/' prior to import?

That is what the Substitute calculation is for. I might have confused you because the example showed how it would be used with an existing path when working at DOS or OS levels on windows (and with some plugins). So just reverse the slashes in the calc.

Can you give me an example of that?

Posted

These are the script steps:

Script Steps

  • Set Variable [ $importdir; Value:Moo_DialogFolder ]
  • Set Field [ IMAGES::folderPathReturned; $importdir ]
  • Send Event [ open document/application; "cmd /c cd " & $importdir & "&&" & "dir /b > filelist.txt" ] [ Bring application to foreground ]
  • Pause/Resume Script [ Duration (seconds): 3 ]
  • Set Variable [ $path; Value:"filewin:/" & $importdir & "filelist.txt" ]
  • Import Records [ Source: “filewin:/C:/Users/owner/Desktop/edit/201479/filelist.txt”; Target: “IMAGES”; Method: Add; Character Set: “Windows -
  • ANSI”; Field Mapping: Source field 1 import to IMAGES::IMAGE1 Source field 33 import to IMAGES::folderPathReturned ]
  • Set Variable [ $recordcreate; Value:IMAGES::record_count_1 ]
  • Go to Layout [ “IMAGES” (IMAGES) ]
  • Set Field [ IMAGES::JPEGPATH; $importdir ]
  • Set Variable [ $$foundCount; Value:Get ( FoundCount ) ]
  • Set Field [ IMAGES::FOUND COUNT; $$foundCount ]
  • Set Field [ IMAGES::counter; 0 ]
  • Loop
  • Set Field [ IMAGES::JPEGPATH; $importdir ]
  • Set Field [ IMAGES::ID; Let ( [ source = IMAGES::JPEGPATH; result = Middle(source;Position(source;"edit";1;1)+5;6) ]; result ) ]
  • Go to Record/Request/Page [ Next; Exit after last ]
  • Set Field [ IMAGES::counter; IMAGES::counter+1 ]
  • Exit Loop If [ IMAGES::counter>=IMAGES::FOUND COUNT ]
  • End Loop

Fields used in this script

  • IMAGES::folderPathReturned
  • IMAGES::record_count_1
  • IMAGES::JPEGPATH
  • IMAGES::FOUND COUNT
  • IMAGES::counter
  • IMAGES::ID

The filewin is just the temporary test using a relative path to test.

Posted

OK, so how about:

Set Variable [ $path ; Value: "filewin:/" & Substitute ( $importdir ; "" ; "/" ) & "filelist.txt" ]

This is assuming $importdir ends with a backslash - otherwise you'll need to change "filelist.txt" to "/filelist.txt".

Posted

OK, so how about:

Set Variable [ $path ; Value: "filewin:/" & Substitute ( $importdir ; "" ; "/" ) & "filelist.txt" ]

This is assuming $importdir ends with a backslash - otherwise you'll need to change "filelist.txt" to "/filelist.txt".

Perfect! Thank you, you are the Filemaker Dali Lama!

This topic is 4764 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.