View Single Post
Old 01-16-2011, 04:19 AM   #10
pchrist7
Addict
pchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animals
 
pchrist7's Avatar
 
Posts: 385
Karma: 6514
Join Date: Aug 2010
Location: Denmark
Device: Kindle 3 3G+Wifi, Oasis
More Brilliant !

Quote:
Originally Posted by chaley View Post
Here is a solution. It works on the example you gave me.
Code:
program:
	comments = field('comments');
	contains(	comments,
				'(?i).*?last page read: location', 
				cmp(re(	comments,
						'(?is).*last page read: location \d+ \((\d+)%\).*', 
						'\1'),
					94,
					'No',
					'No',
					'Yes'),
				'')
The right way to solve this problem is to write a user-defined formatter function in python, something that became possible in 0.7.40. The reason: it is much easier to deal with 'unexpected situations' when writing in python. For example, the above code absolutely depends on the characters in the parenthesis being digits. If they are not, then ugly 'exception' messages get printed.
Hi Chaley

"write a user-defined formatter function in python"
is WAY of out my capabilities at the moment.

DID try your code in a new column, AND it so far looks brilliant !
Books with "read" > 94 goes to Yes status, those below 94 goes to No, and books WITHOUT goes to "blank"
SO - last challenge, I hope, is setting books with NO %read as "No" instead of "blank"

Sorry for all the hassle, on a sunday, but I think other Kindlers would like this besides me.
pchrist7 is offline   Reply With Quote