jEdit Community - Resources for users of the jEdit Text Editor
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Ha, the formatting got all sc
by lg on Mon, 04/04/2011 - 13:40
Ha, the formatting got all screwed up. A new attempt with the > and < replaced with [ and ]

I have an xml with products:

[device]
____[serialNumber]0000007[/serialNumber]
____[a lot of other data]
[/device]

The problem is that all serial numbers are the same. It is easy enough to search for the serial number but I want to increment the value, maybe using beanshell, for every new search hit. Is that possible? My thought was to convert the serial number to an int and increase the number but I guess this requires a global variable to be used as a counter. Can beanshell use global/persistent variables in the search dialog in jEdit? I am a fairly good java programmer but a novice with bsh and would very much appreciate some hints about where to start.
 
Beanshell
by Robert Schwenn on Mon, 04/04/2011 - 20:36
1. Global variables in Beanshell are the ones that are initialized in:
a) a jedit startup script, or
b) the Beanshell console of Console Plugin

2. That said, You have to do 2 things for Your replace:
a) Set the start value of a global counter in Beanshell Console: "k=1"
b. Replace with snippet: "Long.parseLong(_0)+(k++)"

Maybe You need some formatting for the output value in the snippet...

Robert
User login
Browse archives
« December 2014  
MoTuWeThFrSaSu
1
2
3
4
5
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
33%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1092
Syndication
file   ver   dls
German Localization light   4.4.2.1   47367
Context Free Art (*.cfdg)   0.31   37321
JBuilder scheme   .001   11745
R Edit Mode - extensive version   0.1   11483
BBEdit scheme   1.0   11311
ColdFusion scheme   1.0   11299
Advanced HTML edit mode   1.0   10935
Matlab Edit Mode   1.0   10800
jEdit XP icons   1.0   10261
XP icons for jEdit   1.1   10033