Convert chatGPT text to script steps code

Hello all,

I tried searching, but could not find an answer to this.

ChatGPT can produce some starter code for FileMaker script steps.
Is there a way to convert this text code to script steps with some tool such as the MBS plugin or another tool?
Does anyone know if there is a video demo of this functionality?

For example, I asked chatGPT to convert some Python code to a FileMaker script. This python code is being used to update a google spreadsheet daily, with the ETA and delivery times of our trucks.
It was built in python by a previous developer who was proficient in Python and did not know that FileMaker can query an API and get results.

ChatGPT was able to convert this code to a FileMaker script.
I know I could manually create each script step if needed, but would like to know if it can be converted automatically by another tool, to add the required FileMaker xml markup.

Here is some of the sample code that chatGPT wrote:

Allow User Abort [ Off ]
Set Error Capture [ On ]
Set Variable [ $uri ; Value: "wss://socket.fleetfreedom.com/" ]
Set Variable [ $usrName ; "Enter your Username: " ]
Set Variable [ $pswd ; "Enter your Password:" ]

Loop
Set Variable [ $websocket ; Value: New WebSocket ]
Set Variable [ $resp ; Value: $websocket.recv ( $uri ) ]

# Log into FleetFreedom
Set Variable [ $loginRequest ; Value: JSONSetElement ( "{}" ; [ "reqId" ; 1 ; JSONNumber ] ; [ "username" ; $usrName ; JSONString ] ; [ "password" ; $pswd ; JSONString ] ; [ "userAgent" ; "Bryan's FileMaker Script" ; JSONString ] ) ]
Set Variable [ $loginRequestString ; Value: "login " & JSONFormatElements ( $loginRequest ) ]
Set Variable [ $websocketSendResult ; Value: $websocket.send ( $uri ; $loginRequestString ) ]
Set Variable [ $resp ; Value: $websocket.recv ( $uri ) ]
Set Variable [ $respJ ; Value: JSONGetElement ( $resp ; "login" ) ]
Set Variable [ $loginAttempt ; Value: JSONGetElement ( $respJ ; "errorCode" ) ]
Set Variable [ $loginMsg ; Value: JSONGetElement ( $respJ ; "message" ) ]

That would be difficult. Script steps, functions and static text could all be handled because they have fixed IDs. There are a lot of them so you’re looking at a lot of work. Table, field, scripts, anything that you created will be a pain to implement. You’d have to obtain these from XML output.

If you have a clipboard tool that allows to inspect all of the clipboards you can copy a few scripts and inspect the XML.

You also need to be able to put your generated XML into the clipboards as an fmp clipping. That’s probably the easiest part and you can find code on GitHub that does this.

This is both a fascinating and cool endeavor, so I do not wish to discourage you from pursuing it, but I do want to give you a heads up that it looks like ChatGPT wrote code that seems to assume a few things which are not really true.** As such, I think that it will be necessary to re-write/adapt some of the key parts of the script that ChatGPT, in order to get it to work.

**The script seems to assume that a websocket API available in Python is also available in FileMaker, and it has also incorporated some non-FileMaker syntax.

3 Likes

I think there is a solution in one of @mrwatson-de 's tools, I've seen pseudo code translated into working FM code on one of our local user-group meetings

you can look here: http://mrwatson.de/

3 Likes

Yep, you can head over to mrwatson-de (Russell Watson) · GitHub and download fmWorkMate, fmCheckMate xslt library, and maybe fmAutoMate , if you want such powerful tools at your fingertips in your script workspace (Mac only!)

  1. Download fmWorkMate and put the folder in your applications folder
  2. Download fmCheckMate XSLT and put it in your documents folder (so the path ~/Documents/fmCheckMate/bin exists)
  3. Download fmAutoMate and put the folder in your applications folder
  4. Download and install MBS and BaseElements plug-ins
  5. Start fmAutoMate and press the big fmAutoMate button
  6. Copy your above script pseudo code text
  7. Open script Workspace
  8. Create a script and right click in the script step area
  9. Select Code > Insert > Insert Pseudocode from the context menu
  10. Paste your pseudo code text into the dialog box and press OK
  11. Goggle and enjoy
  12. (And this is the important bit) let me know how you get on

…or something like that

Cheers and good night from terribly rainy Germany!

:face_in_clouds::sleeping:

6 Likes

P.S. Tell a Freind! :nerd_face:

2 Likes

Hi @mrwatson-de ,

Thanks for the instructions on how to use your tools.
When I followed your installation and use instructions above, it worked.
The code does not run, which I expected, as many steps have comments. However, I now have the algorithm basis to modify it to work in FileMaker.

I tried to use your tools yesterday, but I could not get them configured correctly and then I did not know which command to use to paste the code. I thought I had to use FM_CheckMate to copy and paste the code, as I use this to transfer code from Mac to Windows.
I did not find these simple instructions on the github page or in your videos.

Please consider making a new video for pasting pseudocode, with detailed steps. In your current video, you say, "press the special key command to paste the script code". However, you don't say what the key command is. However, the steps above clearly told me what to do.

Thanks again.

Hi @MaxBiz ,

I'm glad you've had some success with the tools!

fmCheckMate is the tool for converting FM to XML and back, and via the T button you can tap into a bunch of code analysis and transforming functions in the fmCheckMate XSLT library. All key shortcuts are visible in the menus.

With fmAutoMate you can peruse the context menus and you should find keyboard shortcuts there too. There are 2 pseudo code functions, if I remember correctly (not with my laptop at the mo) the one under Code > Insert which offers a dialog to paste into, the other is under the Clipboard paste menu, which posts the pseudocode directly.

The (very VERY basic) AWK script which converts the pseudo code is in the fmCheckMate bin folder, which is why you need the library for the function.

It can convert a bunch of basic stuff, line-wise - so no multi line calculations! Anything it doesn't recognise is inserted as a comment, so that you can easily build on top of the little bit that the tool manages.

Take a look at the wiki area of the fmAutoMate repo - you might find some documentation there.

Sadly I find little time for videos, but I thought I had done a little video for pseudo code somewhere ???

1 Like