Run Filemaker script from LiveCode

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trevix
Posts: 1064
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Run Filemaker script from LiveCode

Post by trevix » Fri Jan 20, 2012 2:43 am

I found on the web this VBScript that should run a script in FileMaker:

Code: Select all

Set objFM = WScript.CreateObject ("FMPRO.Application")  'open FileMaker
Set objFMfiles = objFM.Documents.Open("Z:\Condivisa Mac_PC\ProvaDB.fp7","") 
objFMfiles.DoFMScript ("Dialogo")  
objFM.Quit
But it does not work.
I tried it also from Access and I got "run-Time error 424, object needed".
Any suggestions ???
Thanks
Trevix
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Run Filemaker script from LiveCode

Post by Mark » Fri Jan 20, 2012 5:22 pm

Hi Trevix,

You can't create VBScript objects in LiveCode. You need to save the syntax to a file and execute it with cscript.exe.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

trevix
Posts: 1064
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: Run Filemaker script from LiveCode

Post by trevix » Mon Jan 23, 2012 10:17 am

Thankyou for your answer.
I succesfully use this (stored on a custom property and launched with a "do TheScript as VBScript") to create a new record in Access from LiveCode:

Code: Select all

set MyDB = CreateObject("ADODB.Connection")
on error resume next
MyDB.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\CCanagrafica2.mdb;User ID=Admin;Password=;Jet OLEDB:System database = ;Jet OLEDB:Database Password="
SQLString = "INSERT INTO ListaIN (Cognome, Nome, Citta, DataNascita) VALUES ('CognDacercare', 'NomDaCercare',' ','12/12/12')"
set rs = MyDB.Execute(SQLString)
if err <> 0 then
result = "_Error|"  & err & "|" & err.description
else
SQLString2 = " SELECT @@IDENTITY"
set rs = MyDB.Execute(SQLString2)
result = rs(0)
end if
set SQLString = nothing
set rs = nothing
MyDB.Close
set MyDB = nothing
and this to run a Access macro:

Code: Select all

Set AccessApp = GetObject("C:\Documents and Settings\CCanagrafica2.mdb", "Access.Application")
AccessApp.DoCmd.RunMacro "GetDataFromMIDA"
AccessApp.Quit
Set AccessApp = Nothing
Why do you say that LiveCode cannot run VB script ?
Trevix
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Run Filemaker script from LiveCode

Post by Mark » Mon Jan 23, 2012 10:59 am

Hi Trevix,

Please, read my reply again. I never wrote that LiveCode can't run VBScript.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

trevix
Posts: 1064
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: Run Filemaker script from LiveCode

Post by trevix » Mon Jan 23, 2012 11:24 am

Solved:
I just needed to add Filemaker LogName and password:

Code: Select all

Set objFM = CreateObject ("FMPRO.Application")  'open FileMaker
Set objFMfiles = objFM.Documents.Open("Z:\Condivisa Mac_PC\ProvaDB.fp7","Admin","") 
objFMfiles.DoFMScript ("Dialogo")  
objFM.Quit
Thanks anyway
Trevix
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Run Filemaker script from LiveCode

Post by Mark » Mon Feb 13, 2012 5:15 pm

Trevix,

Are you running this with the do command or with cscript? Which version of LiveCode are you using?

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

trevix
Posts: 1064
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: Run Filemaker script from LiveCode

Post by trevix » Mon Feb 13, 2012 5:44 pm

I am using a do command with LiveCode 4.6.4

Code: Select all

Do TheScript as "VBScript"
Too bad is not possible to pass parameters (FileMaker does not accept parameters when the scripts come from outside...)

Regards
Trevix
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Run Filemaker script from LiveCode

Post by Mark » Mon Feb 13, 2012 5:49 pm

Thanks. Nice that this is possible.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

trevix
Posts: 1064
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: Run Filemaker script from LiveCode - NEW PROBLEMS

Post by trevix » Sun Nov 25, 2012 5:02 pm

Update:
The following code (liveCode 5.5.3) is supposed to launch a FileMaker script (and return eventual errors to Livecode):

Code: Select all

on error resume next
Set FMApp = CreateObject("FMpro.Application")
Set FMfiles =FMApp.Documents.Open("C:\Users\TrevixB\Documents\CC_SaniMont_fm12\CC_preferenze.fmp12","UserName","Password")
If Err.Number <> 0 Then
  Set FMApp = Nothing
  result = Err.Number 
Else
  FMfiles.DoFMScript ("Script_ToDo")
  If Err.Number <> 0 Then
   result = Err.Number 
  end if
  Set FMApp = Nothing
End If
It works fine on the devolpment but, if run from a standalone, FileMaker "believe" that I am trying to open again the file "CC_preferenze.fm12" (not possible since it is already open and shared trough FileMaker) and it wont let me do it (I've checked the script on the standalone and it is the same as on development) :
Cattura.PNG
Cattura.PNG (10.67 KiB) Viewed 9571 times
The problem, I believe is the CreateObject("FMpro.Application").
It works if I put the script in a text file "thetext.vbs". And it works on the "development" environment but not on "standalone".
I tried to use a GetObject("FMpro.Application") but I've got error (424).
Any idea of what is going on ?
Thanks
Trevix
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

Post Reply