REMINDER:
On December 1, 2018, this forum will be closed to new posts and responses. After that date, you will still be able to view and search the forum. New discussions should take place in the IBM Developer Answers forum.



Apr 9, 2016, 12:38 PM
453 Posts

assign a String to a key stroke

  • Category: Other
  • Platform: All
  • Release: 9.0.1
  • Role: Developer
  • Tags:
  • Replies: 9

When I create a new event I generally always (well almost always) enter a set block of code like say

try{

}catch(e){

//Error Message

}

so in the script editor I would like to assign this block of text to say <ctrl><Alt><B> or ???

I have searched through the Designer Preferences but can't find any place to assign something like this. Would sure save a lot of time as there are several block structures that I use regularly and would be a great assist to be able to assign them to some key strokes. 

Apr 9, 2016, 7:30 PM
589 Posts
hmmm

Is this Java or SSJS?  In Java this is built into the editor that you can "Surround code" by right clicking on the context menu.

In designer there is also the ability to have "Snippets" though that might be Java only as well.

 

Honestly if you want to have a key stroke equal something like this, I likely just need a third party app.  There's a bunch out there and all they do is something like this.  People use them in Word processing for signatures and all that.  That's probably your best bet.

Apr 10, 2016, 1:49 PM
453 Posts
Trying AutoHotKey

I just downloades AutoHotKey which really looks like overkill for what I need but appears to do what I need.

Apr 10, 2016, 5:17 PM
453 Posts
ignore

 

Apr 10, 2016, 5:31 PM
453 Posts
ignore

 

Apr 10, 2016, 5:31 PM
453 Posts
ignore

 

Apr 10, 2016, 5:17 PM
453 Posts
ignore

 

Apr 10, 2016, 5:17 PM
453 Posts
ignore

 

 

Apr 10, 2016, 5:24 PM
453 Posts
AutoHotKey might need so tweaking to work here, but it works fine in the Eclipse JS Editor

I try to set up Script blocks like this

try{

var debug:Boolean = false

}catch(e){

//My error trap

}

so I created this script for an <Alt><b>

!b::
send, try {{}`n
send,  `tvar debug:Boolean = false;`n
send, `n
send, `n
send, {}}catch(e){{}`n
send,  `tWFSUtils.sysOut("" {+} e.toString());`n`n
send, {}}`n
Return

works like a charm going to save a lot of time and spelling/case goofups.

Tried the <Alt><b> in here and the results are above, so key stroke must be unique, but you can set up pretty much any combination you want. <alt><b> is probably not a good choice probably will change that to <Ctrl><Alt><b> or something like that.

Apr 12, 2016, 10:02 AM
300 Posts
Code Snippets
Go to Window, Show Eclipse Views, Other. Search for Snippets and open the code snippets. Right click on the new view and use customize to create/edit the snippets.


REMINDER:
On December 1, 2018, this forum will be closed to new posts and responses. After that date, you will still be able to view and search the forum. New discussions should take place in the IBM Developer Answers forum.