Character Math

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
Guest

Character Math

Post by Guest »

I'm working with an HTML document that has consecutive layers with variable left margins i.e. from 307px to 355px

Is there anyway to do a search and replace using a math operator that would subtract 30px from the above amounts? (355px - 30px = 325px)

something like search= left:3??px -30px
and replace the difference.

Ron
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Post by DataMystic Support »

Hi Ron,

Yes. Use a pattern search and replace to match just the numeric section you need ie the '307' part of '307px'.

Then, use a VBScript SUBfilter, and set the processLine result to

processLine = (line - 30) & EOL
Guest

Post by Guest »

Thanks Simon,

Your suggestion worked like a dream, once I figured out what a VBScript SUBfilter was and how to apply it.

Ron
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Post by DataMystic Support »

Great Ron,

Do you think we need to add a brief tutorial on that? - we have a White Papers and Document Delivery service for that kind of thing

Have you seen the tutorial on restrictions?

http://www.crystalsoftware.com.au/docs
Guest

Post by Guest »

Simon;

A tutorial might be a good idea. I've also downloaded the tutorial on restrictions to see how it can help.

For a pattern search on my project I found I could enter a search string of "355px" and a replace string of "355". This set up the information for the VBScript SUBfilter. I used "processLine = (line - 30) & 'px' & EOL" the result = "325px"...

I didn't know the syntax for VBScript so I just commented out the line count routine of the example script and added my own processLine. I don't know what the rest of the script does but the results work fine.

Ron
sergeda
Posts: 7
Joined: Thu Jan 18, 2007 3:01 pm

Not losing a all text in subfilter?

Post by sergeda »

Hi.
I am trying to make the same thing.
I've done as Ron. Added search and replace filter witch extract only needed number and in subfilter making a math. But I eventualy loosing all other text and get only line of numbers. I can't figure out how to use subfilter to not lose hole text. I've read a white paper about subfilter with no success. Can somebody give me a right direction?
Here is the line from text and my filter:

BenQ-Siemens CF61 12 165.00 5.0900


|--Perl pattern [.*\t(.*)\.00\t.*] with [$1]
| | [ ] Match case
| | [ ] Whole words only
| | [ ] Case sensitive replace
| | [X] Prompt on replace
| | [ ] Skip prompt if identical
| | [ ] First only
| | [ ] Extract matches
| | Maximum text buffer size 4096
| | [X] Maximum match (greedy)
| | [ ] Allow comments
| | [ ] '.' matches newline
| | [ ] UTF-8 Support
| |
| +--VBScript script Timeout: 10000 milliseconds
|
| 'Called for every line in the file
| 'EOL contains the end of line characters (Unix, DOS or Mac) that must be
| 'appended to each line
| function processLine(line, EOL)
| processLine = (line - 2)
| end function
|
|
| 'Called at the start of a processing job -
| 'perform one-time initialisation here
| sub startJob()
| end sub
|
|
| 'Called at the end of a processing job -
| 'destroy any declared objects here
| sub endJob()
| 'do nothing
| end sub
|
|
| 'Called before each file is opened -
| 'perform per-file initialisation here
| function startFile()
| startFile = ""
| end function
|
|
| 'Called before each file is closed -
| 'flush all pending file output here
| function endFile()
| endFile = ""
| end function
|
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Post by DataMystic Support »

Don't use
Perl pattern [.*\t(.*)\.00\t.*] with [$1]
Use the Replace Action to only apply the subfilter to captured variable $1.
Post Reply