Page 1 of 1

Help with/for Scripting

Posted: 05 Oct 2011 23:22
by rjbill
Is there any help or wiki or anything for scripting?
I can't find anything.

There should be a STICKY at the top of this forum that gives some
basic information.

I wanted to write a script, so I looked at it/them, and couldn't find
any information or help, and see that there are several scripting
languages, so I don't even know where to start.

Most editors don't even have one scripting language, much less several
to choose from.

This forum has a bunch of information, but, again, where would
a person even start to read?

Re: Help with/for Scripting

Posted: 06 Oct 2011 00:32
by rjbill
I found some info in help.
But I can't even figure out how to do a simple search,
much less a regex search.

All I want to do is find the QB64 FUNCTION or SUB routine in the editor
using the selected text or the word the cursor is on (or at the front or rear of)
if no selection.

So the regex would be something like:

^(FUNCTION|SUB) +name

And, since "name" can have '$' and possibly other regex characters,
I either need to slash-quote it or use a function that does that. Like:

^(FUNCTION|SUB) +PARSE\$

So it's a relatively simple script, if you know how the scripting stuff works.

I would also like Previous FUNCTION/SUB and Next scripts so I can quickly
jump up and down through routines. (maybe an "End of FUNCTION/SUB" script)

Re: Help with/for Scripting

Posted: 06 Oct 2011 11:56
by pjj
Ralph,

I may be wrong on this, but I believe RJ TE uses FastScript as its scripting engine:
FASTSCRIPT - multi-language scripting engine

FastScript is a cross-platform, multi-language scripting engine. It is useful for programmers who want to add scripting ability to their projects. FastScript can be installed in Embarcadero (ex Borland and CodeGear) Delphi 4-XE2, C++Builder 4-XE2, Kylix 1-3 and Lazarus.
An unique feature of FastScript is its ability to use several languages (PascalScript, C++Script, JScript and BasicScript). This allows you to write scripts using your favorite language. FastScript doesn't use Microsoft Scripting Host, so it can be used in both the Windows and Linux environments.

FastScript offers a wide range of features, including cross-platform scripting, fast code execution, a small footprint, a great variety of tools, and excellent scaling options. Use FastScript to make your applications really flexible and powerful!

http://www.fast-report.com/en/products/fast-script.html
I once intended to give scripting a go, but... well, yeah, no time. Anyway, here: http://www.fast-report.com/en/support/ you can find some documents to download, plus FAQs, newsgroups and a forum. Hope that helps!

Re: Help with/for Scripting

Posted: 06 Oct 2011 17:20
by jgodfrey
rjbill wrote:ISo it's a relatively simple script, if you know how the scripting stuff works.
I'm not sure you can do a regex search in a script (though that would be nice). While a regex would make it easier, it's certainly not necessary in this case. Here are a few pointers:
  • - Get the current selection using Document.SelText()
    - Modify the selection if necessary using Document.CursorWordLeft(true) and Document.CursorWordRight(true)
    - Get the number of lines in the document using Document.LineCount()
    - Iterate through the lines of the file (up or down) using a simple for loop, and reference the current line using Document.Lines(i), where i is your loop indexer.
    - Search for some text in the current line using the Pos(substring, string) function
    - Move the cursor using the Document.CursorX and Document.CursorY properties
That should be most of the machinery required for your script.

Jeff

Re: Help with/for Scripting

Posted: 06 Oct 2011 17:54
by rjbill
Thanks.

I figured out the FastScript thing.
But it has been 'attached' to the editor, with editor objects
and methods and properties and such, which are proprietary.

I figured out the Document.SelText and a couple of other things,
but didn't want to do a hardcoding-type implementation.
I guess Rickard is just adding stuff to the interface as he can and wants to.

It's strange that it doesn't do regex searches and replaces.
I couldn't even find "search", just "replace all".

Maybe someday there will be better documentation.

Re: Help with/for Scripting

Posted: 06 Oct 2011 18:04
by jgodfrey
rjbill wrote:I figured out the Document.SelText and a couple of other things,
but didn't want to do a hardcoding-type implementation.
I'm not sure I follow. You don't really need to "hardcode" anything outside of the actual search logic. The script can certainly operate on the selected item, or select the item to the left or right as you suggested based on whatever logic you want to employ.
rjbill wrote:I guess Rickard is just adding stuff to the interface as he can and wants to.
The current scripting interface is definitely a little "light" in some areas, though it seems to have the basic machinery necessary to do lots of common things - including what you're trying to do. That said, some additions could make it easier. Rickard has added a few things for me as I've needed them, so I'm sure he's not opposed to User requests...
rjbill wrote:Maybe someday there will be better documentation.
I find that poorly documented scripting is the downfall of many "scriptable" applications. However, I think RJTE's scripting docs are *much* better than some other scriptable apps I've dealt with (though they could certainly be improved also).

Jeff

Re: Help with/for Scripting

Posted: 06 Oct 2011 18:27
by rjbill
I meant "brute force" (not hardcoding-type), rather than a more elegant solution.

In some ways the docs are good. However, that doesn't help due to the proprietary
nature of the implementation, so they might as well not be there at all.

It's like if you got a programming language manual that listed all of the commands,
but didn't tell you what they did, what the parameters are (rather than just type), etc.

That would be pretty useless. (unless there was other info around the net that
you could find to piece it all together)

Re: Help with/for Scripting

Posted: 06 Oct 2011 20:23
by jgodfrey
rjbill wrote:I meant "brute force" (not hardcoding-type), rather than a more elegant solution.
I guess it depends on how badly you want the custom functionality. You can certainly create it now (with no scripting enhancements), though it may take a little more effort on your part than you might have hoped.

Jeff

Re: Help with/for Scripting

Posted: 06 Oct 2011 22:55
by jgodfrey
In addition to my above reply, see this topic:

http://www.rjsoftware.se/Forum/viewtopi ... =11&t=1982

Jeff

Re: Help with/for Scripting

Posted: 17 Mar 2012 20:41
by dustwalker
If you do a regex search in RJ TextEd, and then run a script, the script's Document.ReplaceAll() lines will use regex. In older versions of RJ TextEd, you did not have to do a regex search, only to activate the RJ TextEd's button, but it changed at some point.

Regards