External Editor . . . on and on

Richmond richmondmathewson at gmail.com
Wed Oct 23 09:50:18 EDT 2013


I suppose I'm going to have to trawl through the last 10 versions of 
MetaCard to find the "Set External Editor" code
referred to in the 'Help' (possibly a misnomer) file, as it in certainly 
not present in 4.1 not in 2.4.

Richmond.

On 22/10/13 22:58, Richard Gaskin wrote:
> Looking at the most recent build of the MC IDE (v4.1), in the stack 
> "Script Editor" there's an item named "Run External Editor..." in the 
> Tools menu.
>
> That menu button's script includes:
>
>    on menuPick which
>    ...
>      case "Run External Editor..."
>        if the selectedLine is empty
>        then runexternal 0
>        else runexternal word 2 of the selectedLine
>        break
>
>
> So looking in the card script I find:
>
>    on runexternal whichline
>      local ename, fname, dummy
>      put mcGetPref("external editor") into ename
>      put tempname() into fname
>      open file fname for write
>      write field "Editor Field" & cr to file fname
>      close file fname
>      put "See External Editor..." into field "Editor Field"
>      set the cursor to watch
>      if whichline is empty then put 1 into whichline
>      put shell(ename && "+" & whichline && fname) into dummy
>      open file fname for read
>      read from file fname until eof
>      if the last char of it is cr then delete last char of it
>      put it into field "Editor Field"
>      close file fname
>      delete file fname
>      select after line whichline of field "Editor Field"
>      put setscript(true) into fname
>    end runexternal
>
>
> If I were implementing this today I'd do it differently:
>
> 1. Write the script to tmp
> 2. Launch editor with script as document
> 3. Poll for changes
> 4. set the script of the object to the contents of the changed file
>
> There are probably many other ways to do it, but back when I was using 
> MC I just made my own editor, and now with LC I find it's not bad so I 
> just use it.
>
> -- 
>  Richard Gaskin
>  Fourth World
>  LiveCode training and consulting: http://www.fourthworld.com
>  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
>  Follow me on Twitter:  http://twitter.com/FourthWorldSys
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list