[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Poco Forums • View topic - Edit PocoScripts in an external editor

Edit PocoScripts in an external editor

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Edit PocoScripts in an external editor

Postby Hogyt » Thu Aug 12, 2004 6:37 am

This script provides an easy way to edit scripts in an external editor. I use it to edit scripts in the awesome free text editor PSPad.

Code: Select all
{ External edit.poc - Provides external editing of scripts
{ V1.01 - 12/08/04
{ See http://www.pocosystems.com/forum/viewtopic.php?t=256 for more info
{ Changelog: V1.01 - Displays the editor name in inputbox message
{                  - No longer checks to see if script exists, that way new scripts can be created

Set $OnErrorGoTo "ErrorHandler"

{ Check we're running in manual mode
If #PocoScriptMode = 5 Then Jump
  Set $message "The 'External edit' script can only be run in manual mode"
  MessageBox $message
Exit

:Jump
{ Read external editor
ImportVar $path

If $path ! "" then Jump2

{ If path is blank set it to default
Set $path "C:\\Windows\\Notepad.exe"
{ Export this value
ExportVar $path
{ Import this value to refresh setup script screen
ImportVar $path

:Jump2
{ Check external editor exists
FileExists &test $path

If &test Then Jump3
   Set $message "Cannot find the external editor:\n"
   AddStrings $message $path
   MessageBox $message
Exit

:Jump3
{Provide option to type in external editor
External $path "Full path of external editor" "C:\\Windows\\Notepad.exe"

{ Read previously selected PocoScript
ImportVar $value

{ Read list of scripts in default script path
DirList $dir $scriptpath "*.poc"
LineCount #lines $dir

{ Set default value as previously selected file
Set $disp $value
AddStrings $disp "|"

Set #index 0

{ Arrange scripts in format for InputBox
:Loop
   GetLine $line #index $dir
   String
   AddStrings $disp $line "|"
   Inc #index
   If #index < #lines Then Loop

{ Ask which script to view
Set $message "Select a script to edit or enter a new name with .poc extension to create a new script\n"
AddStrings $message "Chosen editor:\n" $path "%var%"
InputBox $value $message $disp

{ Save this value ready to show as default value next time
ExportVar $value

{ Check selected PocoScript exists
Set $check $scriptpath
AddStrings $check $value

{ Wrap quotes around the PocoScript filename
Set $params \"
AddStrings $params $check \"

{ Run the external editor with the selected PocoScript as parameter
Execute $path $params

Exit

:ErrorHandler
Set $message "An error has occurred\n"
AddStrings $message "$ErrorResult: " $ErrorResult " $ErrorLine: " $ErrorLine
MessageBox $message
Exit


Save it in your scripts folder as External edit.poc and set up a button to run it (if you like). It gives an input box of your scripts and remembers the last script run. You can set the editor of your choice by going to the "Setup Script" screen in Tools->Scripts, typing in the path to your favourite editor and then clicking on "Edit Script". This last click ensures the editor is saved.

Screenshot:
Image
Hogyt
Poco Enthusiast
 
Posts: 241
Joined: Thu Jul 29, 2004 11:22 am
Location: England

Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 2 guests

cron