Problems with initial value of global var

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

sellb
Posts: 2
Joined: Sat Aug 09, 2008 1:03 am
Location: Berlin

Problems with initial value of global var

Postby sellb » Sat Aug 09, 2008 1:25 am

Hi,

I like to search big htm-files for certain signalwords, then extract the information that follow-up these signalwords and put them in a form that is friendly for *.csv . I do it using global vars and but there is a problem. It looks like this:

The htm-files look like this:

1.htm

fdskjfhsd
votes
9876
sdfsdf

2.htm
sdfsdf
votes
14323

3.htm
sdfdsgf
asfddsf
asdsa

What I do is:

restrict to lines matching ^votes (with context line 1 After the match)
--> subfilter
capture to variable "votes" ([X] Reset to initial value at start of each file) with the Initial Value .

then I remove all the content of the htm and add a header with the value of votes (@votes). Finally I append everthing in one *.csv

generally this works well, but not so well if textpipe doesnt find "votes", like in 3.htm in my example. then the result is NOT

9876
14323
.

..as I expected it to be but:

9876
14323
14323

..which gives me the impression the RESET doesnt work... what can I do to ensure a proper reset to the initial value?

greetings
S.

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

Re: Problems with initial value of global var

Postby DataMystic Support » Mon Aug 11, 2008 8:43 am

Since your capture is inside a subfilter, you need to reset at the start of each Region (and/or file), as subfiltered text is treated slightly differently to a file.

Also- note that you can Copy/Paste a filter as text like that below:

Restrict to lines matching [^votes]
| [ ] Include line numbers
| [ ] Include filename
| [ ] Match case
| [ ] Count matches
| Pattern type: 0
| Context before: 0
| Context after: 1
|
+--Capture to variable @votes
Reset for both
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

sellb
Posts: 2
Joined: Sat Aug 09, 2008 1:03 am
Location: Berlin

Re: Problems with initial value of global var

Postby sellb » Thu Sep 11, 2008 1:39 am

thanks, as you suggested I just added a

Capture to variable @varname

outside the RESTRICTED subfilter and now it works.


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest