Notetab Clip to Make Tab Delimited File into Comma Separated Value CSV File
December 6, 2007 on 12:08 pm | In Generic Clips, Notetab Clips | No CommentsThis clip makes a file into a comma separated value file if it is say tab delimited at the start. It offers several choices of delimiters to start including comma, semi-colon, colon, tabs, etc.
EPOCH Time from System Time Using Notetab Clip
April 15, 2007 on 6:53 pm | In Generic Clips, Notetab Clips | 1 CommentI want to do a time comparison between two times. I figured a good way to do that might be to generate a Unix or EPOCH time as is commonly used in Perl, PHP, and many other programming languages. I searched help and help on clip programming and did not find any reference to EPOCH time in either, so I decided I was on my own.
My method is set out in the beginning of the clip in a comment. I did take into account leap years (skipping over the issue that ever other century or so you skip a leap year even though the year is divisible by four…or something like that). I think it is working. I may in my next go let you set a random time. Currently this is outputting most interim data calculated, but I obviously would modify that for a final product.
Here is the NoteTab Pro Clip to generate EPOCH time from the system time. You can check your results using an EPOCH to human time converter.
;*** Effort by Don Passenger
;*** don at htmlfixit dot com
;*** Creates EPOCH Time (seconds since Jan 1, 1970 to current)
;*** from time on computer
;*** copy posted at:
;*** http://htmlfixit.com/blog/?p=356
;*******************************************************
^!InsertText +++++++++++++++++get date off system++++++++++++++++++++++^P
:GrabDates
;get year
^!Set %year%="^$GetDate(yyyy)$"
;get month (no leading zeros)
^!Set %month%="^$GetDate(m)$"
;get days (no leading zeros)
^!Set %day%="^$GetDate(d)$"
;get hours (no leading zeros)
^!Set %hours%=^[h^]
;get minutes (no leading zeros)
^!Set %minutes%=^[n^]
;get seconds (no leading zeros)
^!Set %seconds%=^[ss^]
:FigureEpochTime
;Method Used:
;base year (from Jan 1 70 to Jan 1 2007)
;+ seconds in each year after 2006
;+ seconds in each month in current year
;+ seconds in days up to today
;+ seconds in hours, minutes, seconds of today
;I disregard leap seconds and figure I'll
;be dead before the next non-leap year
;divisible by four
:CalculateSecondsInYearsFrom2006
^!InsertText ++++++++++++++calc seconds in years after 2006++++++++++++++++++^P
;calculate days in years between 12/31/2006
;and current year (whole years only)
^!Set %baseyear%="2006"
^!Set %numberofyears%="^$Calc(^%year%-2006-1)$"
:Loop_years_to_seconds
^!Set %counter%="0"
^!Set %secondsinyears%="0"
;skip years entirely if is currently 2007
^!If ^%numberofyears% = 0 Loop_months_to_seconds
:next_year
;first time thiw becomes 2007 and then it
;counts up to current year
^!Inc %baseyear%
;set days in month for non-leap years
^!SetArray %daysinmonth%=31;28;31;30;31;30;31;31;30;31;30;31
;determine if year being worked on is leap year
;fix Feb days if yes
^!If ^$calc(^%baseyear% mod 4)$<>0 Skip
^!Set %daysinmonth2%=29
:calcsecondsinyears
;abort any time we are out of whole years 2007-
^!If ^%numberofyears% = 0 Loop_months_to_seconds
;in counter so that we can get days in each month of year
^!Inc %counter%
;add to seconds in year the active month in the active year
^!Set %secondsinyears%=^$Calc(^%secondsinyears%+(^%daysinmonth^%counter%%*86400))$
;this is just for testing to show the output after each month
;while calculating the active year
^!InsertText ^%secondsinyears% to ^%baseyear%-^%counter% ^$Calc(^%secondsinyears%+1167609600)$^P
;do the next month in active year unless we are at 12 (ie no more months)
^!If ^%counter% <> 12 calcsecondsinyears
;reduce years to be calculated by one and recycle to calc seconds in next year
^!Dec %numberofyears%
;reset month counter to zero
^!Set %counter%="0"
;goto next year 2008-
^!Goto next_year
:Loop_months_to_seconds
^!InsertText ++++++++++++++++++calc seconds in whole months of current year++++++++++++++++^P
;calculate days in whole months for current year
;set the months to 0 so we can process each month
^!Set %basemonth%="0"
;start the base counter
^!Set %secondsinmonths%="0"
;get us out of here if it is Jan
^!If ^$Calc(^%basemonth%+1)$ = ^%month% Loop_days_to_seconds
;set months array for non-leap years
^!SetArray %daysinmonth%=31;28;31;30;31;30;31;31;30;31;30;31
;if current year is leap year, correct Feb
^!If ^$calc(^%year% mod 4)$<>0 Skip
^!Set %daysinmonth2%=29
:next_month
;start with month 1 (Jsn first time and increas by one each time)
^!Inc %basemonth%
;if it is current month we are done with months
^!If ^%basemonth% = ^%month% Loop_days_to_seconds
:calcsecondsinmonths
;do math to get seconds in current month and add to prior months we calculated
;on previousl iterations of this
^!Set %secondsinmonths%=^$Calc(^%secondsinmonths%+(^%daysinmonth^%basemonth%%*86400))$
;insert text is just for testing so we can see we are where we belong at the end of
;each successive month of calculation
^!InsertText ^%secondsinmonths% to Month-^%basemonth% ^$Calc(^%secondsinmonths%+^%secondsinyears%+1167609600)$^P
;repeat until we hit current month (tested above)
^!Goto next_month
:Loop_days_to_seconds
^!InsertText +++++++++++++++++++++calc seconds for whole days current month+++++++++++++++++^P
;set base variable for calculation of seconds in whole days in current month
^!Set %baseday%="0"
^!Set %secondsindays%="0"
:next_day
;increment baseday to 1 first iteration and increasing on each pass
^!Inc %baseday%
;get us out of here when no more full days left to calc
^!If ^%baseday% = ^%day% Loop_hours_to_seconds
:calcsecondsindays
;do math adding second for active day to prior whole days of seconds in current month
^!Set %secondsindays%=^$Calc(^%secondsindays%+86400)$
;insert text just for testing to see if we are where we belong
^!InsertText Current Month Day-^%baseday% ^$Calc(^%secondsindays%+^%secondsinmonths%+^%secondsinyears%+1167609600)$^P
;repeat until we are out of whole days in current month (tested above)
^!Goto next_day
:Loop_hours_to_seconds
^!InsertText +++++++++++++++++++++++Calc Whole Hours Today to Seconds++++++++++++++++++++++++++++++^P
;calculate seconds in whole hours today
;set the hours to 0 so we can process each one
^!Set %basehour%="0"
;start the base counter
^!Set %secondsinhours%="0"
;get us out of here if it is < Midnight+1hour
^!If ^$Calc(^%basehour%+1)$ = ^%hours% Loop_minutes_to_seconds
:next_hour
;start with hour 1 (12:00:01am first time and increase by one each time)
^!Inc %basehour%
;if it is current month we are done with months
^!If ^%basehour% > ^%hours% Loop_minutes_to_seconds
:calcsecondsinhours
;do math to add 3600 seconds to total for this hour
^!Set %secondsinhours%=^$Calc(^%secondsinhours%+3600)$
;insert text is just for testing so we can see we are where we belong at the end of
;each successive month of calculation
^!InsertText Seconds in Hour ^%basehour% ^$Calc(^%secondsinhours%+^%secondsindays%+^%secondsinmonths%+^%secondsinyears%+1167609600)$^P
;repeat until we hit current month (tested above)
^!Goto next_hour
:Loop_minutes_to_seconds
^!InsertText +++++++++++++++++++Full Minutes to Seconds Plus Seconds++++++++++++++++++++++++++^P
;calculate seconds in whole minutes today AND the REMAINING SECONDS TOO
^!Set %secondsinminutes%=^$Calc((^%minutes%*60)+^%seconds%)$
;insert text is just for testing so we can see we are where we belong at the end of
;each successive month of calculation
^!InsertText EPOCH TIME: ^$Calc(^%secondsinminutes%+^%secondsinhours%+^%secondsindays%+^%secondsinmonths%+^%secondsinyears%+1167609600)$^P
^!Goto end
Notetab Clip to Search Google For Term
January 3, 2006 on 8:39 am | In General, Generic Clips, Notetab Clips | No CommentsOkay, I often search Google to find Notetab’s great Yahoogroups messages. I find the search utility in YahooGroups to be fairly limiting. Tonight RP Dooling — the author – suggested that a clip might be in order … and that got me to thinking. Here is the first in what could easily be a series of clips to search.
This one will limit its search to Yahoogroups that contain the word notetab, either the term you have highlighted when you select the clip, or in the alternative, it will prompt you for a search term to add. It then fires up Google an it is off to the races.
So here it is …
;*** Effort by Don Passenger
;*** don a-t htmlfixit d-o-t com
;*** discuss things live in chat at http://htmlfixit.com
;*** donations welcome at http://htmlfixit.com
;*** Search Google for Notetab Messages
;*** based on Utilities Library + RP Doolings Idea
;START
; Clear variables
^!ClearVariables
^!If ^$GetSelSize$ > 0 HaveSelection ELSE NoSelection
:HaveSelection
^!Set %SearchTerm%=^$GetSelection$
^!Goto TheSearch
:NoSelection
^!Set %SearchTerm%=^?{Type in All Search Terms Separated by a Space}
^!Goto TheSearch
:TheSearch
;replace all spaces in search term with +
^!Set %SearchTerm%=^$StrReplace(" ";"+";"^%SearchTerm%";0;0)$
;replace all quotes in search term with %22
^!Set %SearchTerm%=^$StrReplace(""";"%22";"^%SearchTerm%";0;0)$
^!URL http://www.google.com/search?q=site%3Ahttp%3A%2F%2Fgroups.yahoo.com+notetab+^%SearchTerm%
;line 25 if no lines are wrapped
Smart Definition List Creation Clip
December 26, 2005 on 5:42 pm | In General, Generic Clips, Notetab Clips | No CommentsThis clip will create a definition list in html coding.
Features:
- it will create a blank list with specified number of dt and dd tags in ratio to each other
- it will create a dl from a highlighted list using either every other, a set ratio or custom set determination of what is a dt and what is a dd
- it will specify an id or class for the dl for those using css
;*** Effort by Don Passenger
;*** don a-t htmlfixit d-o-t com
;*** discuss things live in chat at http://htmlfixit.com
;*** donations welcome at http://htmlfixit.com
;*** Create a Definition List (DL) in HTML file v2.0
;*** based on the ordered/unordered clip shipped w/ Notetab
;*** posted here: http://htmlfixit.com/blog/index.php?p=331
;*** this version 2.0 involves some code improvements suggested
;*** or inspired by Bob McCallister fortiter at gmail dot com
;START
; Clear variables
^!ClearVariables
^!Set %listID%=^?{Give list an ID (or leave blank)=}; %listClass%=^?{Give list a Class (or leave blank)=}
^!If "^%listID%" = "" skip
^!Set %listID%=" id='^%listID%'"
^!If "^%listClass%" = "" skip
^!Set %listClass%=" class='^%listClass%'"
^!If ^$GetSelSize$ > 0 FormatSelection
;line 22
:CreateBlank
^!Set %CountDT%=^?{How many Definition Terms (DT):?=1|2|_3|4|5|6|7|8|9}
^!Set %CountDD%=^?{How many Definition Descriptions (DD) per (DT)?=_1|2|3|4|5|6|7|8|9}
^!InsertHtml <dl^%listID%^%listClass%>^P^$StrFill( <dt></dt>^P^$StrFill( <dd></dd>^P;^%CountDD%)$;^%CountDT%)$</dl>^P
^!Goto End
;line 29
:FormatSelection
;Divide selection at paragraph marks to make list
^!SetListDelimiter ^p
^!SetArray %delimited_data%=^$GetSelection$
;figure out if it is just every other one?
^!Set %pattern%="^$StrUpper("^?{Is There a Set Pattern?=_Every Other|Set Ratio|NO}")$"
;^!Set %pattern%=^$StrUpper("^?{Is There a Set Pattern?=_Every Other|Set Ratio|NO]")
^!If "^%pattern%" = "NO" BuildCustom
^!If "^%pattern%" = "SET RATIO" SetRatio
;set to one for every other
^!Set %dd%="1"
^!Goto BuildRatio
:SetRatio
^!Set %dd%=^?{How many (DD) Per (DT):?=1|_2|3|4|5|6|7|8|9}
^!Goto BuildRatio
;line 49
:BuildRatio
;should I test if the ratio works?
;maybe modulus on number if items
^!Set %Count%="1"
:CreateRatioDL
^!InsertHtml <dl^%listID%^%listClass%>^P
:CreateRatioDT
^!InsertHtml ^$StrFill(" ";2)$<dt>^%delimited_data^%Count%%</dt>^P
^!Inc %Count%
^!Set %CountDD%=^%dd%
:CreateRatioDD
^!InsertHtml ^$StrFill(" ";4)$<dd>^%delimited_data^%Count%%</dd>^P
^!Dec %CountDD%
^!Inc %Count%
^!If ^%CountDD% = 0 TestDT ELSE CreateRatioDD
:TestDT
^!If ^%Count% < ^%delimited_data0% CreateRatioDT
^!InsertHtml </dl>^P
;end of Build Ratio
^!Goto End
;line 77
:BuildCustom
^!Set %Count%="1"
:CreateCustomDL
^!InsertHtml <dl^%listID%^%listClass%>^P
:CreateCustomSwitch
^!Set %ThisItem%=^?{Is ^%delimited_data^%Count%% a(DT) or (DD):?=T|_D}
^!If "^%ThisItem%" = "D" CreateCustomDD ELSE CreateCustomDT
:CreateCustomDT
^!InsertHtml ^$StrFill(" ";2)$<dt>^%delimited_data^%Count%%</dt>^P
^!Goto TestCustomDT
:CreateCustomDD
^!InsertHtml ^$StrFill(" ";4)$<dd>^%delimited_data^%Count%%</dd>^P
^!Goto TestCustomDT
:TestCustomDT
^!Inc %Count%
^!If ^%Count% > ^%delimited_data0% CreateCustomDone
^!Goto CreateCustomSwitch
;line 101
:CreateCustomDone
^!InsertHtml </dl>^P
^!Goto Done
:Done
;if done say so
^!Info Done
;========= End =========
;line 111
Image Wrap Clip
December 17, 2005 on 2:18 pm | In General, Generic Clips, Notetab Clips | 1 CommentThis clip will wrap images into xhtml pages for viewing. It works like this:
1. all files must be closed before the clip is run
2. you will want to have your image in their own directory on the computer
3. you click on begin new index … it will ask if all files are closed … if yes, click continue
4. pick your directory using the little “…” button and give the “index” file a name
5. pick your images (you can use the control button to pick multiples
6. hang onto your hat and hold your breath because before you need to breath again you’ll have images each in their own html file with an index file
= V5 MultiLine NoSorting TabWidth=30
H=";ImageWrap - One Click"
==========================================
Adapted from an original by Joe Barta jbarta a-t apk d-o-t net
http://junior.apk.net/~jbarta/image-wrap/
==========================================
Convert a group of images into a suite of HTML pages linked from a
single index page. The index file Mmust be created in a directory
above (or in the same directory as) the images.
Close all NoteTab files before running this clip.
You can customise the HTML files by digging into the clips "_wrapper"
and "_index".
H="Begin new index"
^!Continue Are all files closed? If not - cancel and save, then restart.
^!Save As ^?[(T=S;F="All Files (*.*)|*.*")Name and path for index file=piclist.html]
^!Set %bgcolor%=^?[Background color (select or enter your own hex code)=_FFFFFF (White)^=FFFFFF|000000 (Black)^=000000]
^!Set %txtcolor%=^?[Text color (select or enter your own hex code)=FFFFFF (White)^=FFFFFF|_000000 (Black)^=000000]
^!Set %doc_title%=^?[Set a title for HTML files? (leave blank for none)=Image collection]
^!SetWordWrap Off
:ImageSelect
^!Jump TEXT_END
^?{(T=O;S=M;F="Image files (*.gif;*.jpg;*.png)|*.gif;*.jpg;*.png")Select files to be indexed:}
; Make item-per-line list removing semi-colons or quotes
^!SetCursor 1:1
^!Replace ; ^P ATIWS
^!SetCursor 1:1
^!Replace " ATIWS
^!Skip Image list complete?
^!Goto ImageSelect
^!SetScreenUpdate Off
;get the base path of the file list
^!Set %base_path%=^$GetPath(^$GetDocName$)$
;get the name of file
^!Set %base_name_1%=^$GetFileName(^$GetDocName$)$
;get the total lines and initialize line count
^!Set %total_lines%=^$GetLineCount$
^!Set %current_line_number%=1
;Set up a pasteboard
^!ToolBar New Document
; go to loop
^!Clip "operate"
; tidy up on return
;kill the pasteboard
^!Document LAST
^!DestroyDoc
;now we're at the file list
^!SetCursor 1:1
^!Select ALL
^!Clip "index"
^!ToolBar Save Document
^!Prompt All done!
H="_operate"
^!SetWordWrap Off
^!Document FIRST
^!SetCursor ^%current_line_number%:1
^!Select EOL
^!ToolBar Copy
; grab image particulars
^!Set %full_disk_path%=^$GetClipboard$
^!Set %img_width%=^$GetImgWidth(^$GetClipboard$)$
^!Set %img_height%=^$GetImgHeight(^$GetClipboard$)$
^!Set %image_name%=^$GetName(^$GetClipboard$)$
^!Set %image_ext%=^$GetExt(^$GetClipboard$)$
;get the relative disk & web path of the image to the file list
^!Document NEXT
^!ToolBar Clear All
^!InsertText ^%full_disk_path%
^!SetCursor 1:1
^!Replace ^%base_path% ATIWS
^!SetCursor 1:1
^!Replace / ATIWS
^!SetCursor 1:1
^!Select EOL
^!ToolBar Cut
^!Set %relative_web_path%=^$GetClipboard$
; build a save as filename out of the full_disk_path
^!ToolBar Clear All
^!SetCursor 1:1
^!InsertText ^%full_disk_path%
^!SetCursor 1:1
^!Replace .gif _gif ATIWS
^!SetCursor 1:1
^!Replace .jpg _jpg ATIWS
^!SetCursor 1:1
^!Replace .png _png ATIWS
^!SetCursor 1:1
^!Select EOL
^!ToolBar Cut
^!Set %full_disk_html_path%=^$GetClipboard$.html
; build a href out of the relative web path
^!ToolBar Clear All
^!SetCursor 1:1
^!InsertText ^%relative_web_path%
^!SetCursor 1:1
^!Replace .gif _gif ATIWS
^!SetCursor 1:1
^!Replace .jpg _jpg ATIWS
^!SetCursor 1:1
^!Replace .png _png ATIWS
^!SetCursor 1:1
^!Select EOL
^!ToolBar Cut
^!Set %href_html_path%=^$GetClipboard$.html
;make a nifty wrapper file
^!ToolBar New Document
^!Clip "wrapper"
^!Save As ^%full_disk_html_path%
^!ToolBar Close Document
^!Set %link%=<LI><A HREF="^%href_html_path%">^%image_name%
(^%image_ext%)</A></LI>
;go to the list and insert the link in place of the existing line
^!Document FIRST
^!SetCursor ^%current_line_number%:1
^!Select EOL
^!ToolBar Cut
^!InsertText ^%link%
; Stop when line count gets to the end of the list
^!Set %current_line_number%=^$Calc(^%current_line_number%+1;0)$
^!IF ^%current_line_number%=^%total_lines% EXIT
^!Clip "operate"
:EXIT
H="_wrapper"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>^%doc_title%</title>
<!-- Created with ImageWrap
http://junior.apk.net/~jbarta/image-wrap/
as modified by don from http://htmlfixit.com
and fortiter at gmail dot com
-->
<style type="text/css">
<!--
body {background-color:#^%bgcolor%;}
h2, li, li a {color:#^%txtcolor%;}
-->
</style>
</head>
<body>
<center>
<img src="^%image_name%^%image_ext%"
width="^%img_width%"
height="^%img_height%"
alt="^%image_name%"
border="0" />
<p><a href="^%base_name_1%">Return to Image Menu</a></p>
</center>
</body>
</html>
H="_index"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>^%doc_title%</title>
<!-- Created with ImageWrap
http://junior.apk.net/~jbarta/image-wrap/
as modified by don from http://htmlfixit.com
and fortiter at gmail dot com
-->
<style type="text/css">
<!--
body {background-color:#^%bgcolor%;}
h2, li, li a {color:#^%txtcolor%;}
-->
</style>
</head>
<body>
<h2>^%doc_title%</h2>
<ul>
^&
</ul>
</body>
</html>
Hyperlink with Image
November 26, 2005 on 2:23 pm | In Generic Clips, Notetab Clips | 3 CommentsThis is a clip that I wrote a while back, but enhanced as a result of this post to the ntp-clips list:
Hi all, Was wondering if anyone knew of a clip which provided more options when inserting links into pages? Specifically, I'm seeking a clip which gives me the option of inserting the following anchor info: * NAME * HREF * TARGET * IMG SRC * IMG HEIGHT Ideally these two would be completed * IMG WIDTH / for me, based on the IMG SRC. * IMG BORDER * IMG ALT * IMG ALIGN Is there such an HTML clip? Many thanks! Catherine
So here goes nothing, a clip to insert an image surrounded by a hyperlink that allows you to set the following attributes:
- target for the link
- name for the image (or did she mean for the hyperlink?)
- name for the link (see her comment below)
- image border
- image alignment
All of the other things she wanted are standard in the clips shipped with notetab.
So here is the clip …. note that there is one very long line in this clip that will break if you email it to someone.
; by: don at htmlfixit dot com
; creates a hyperlink from an image to a file
; fills in info about the image and prompts for
; target/name/alt/border/align attributes
; copy stored at: http://htmlfixit.com/blog/index.php?p=326
;I would like to get this running in one wizard
^!SetWizardLabel "Pick a File To Link To and Enter Value for Attributes"
; long line next (it needs to be unwrapped if you copy this)
^!InsertWizardHtml <A ^?[(T=T;F="Link Files|*.*htm*;*.php;*.pl;*.cgi")&Select the File to Link To] NAME="^?{Link &name=^&}" TARGET='^?[&Target (transitional)=blank^=_blank|parent^=_parent|self^=_self|top^=_top]'><IMG ^?{(T=T;F="Image Files|*.gif;*.png;*.jpg;*.jpeg")&browse to find image} NAME="^?{Image &name=^&}" BORDER="^?[(T=C)border level==_0|1|2|3|4|5|6]" ALIGN="^?[(T=C)align imgage==_left|right]" ALT="^?{Image text &description=^&}"></A>
; end of long line
; replace any double quotes with single
; better form to only use double when necessary
^!Replace " >> ' ATHS
:End
Delete All <a href> and <\a> Tags from a Document
June 14, 2005 on 10:22 pm | In General, Generic Clips | No CommentsThis clip will remove all and tags from a document. This includes all links, including all mailto: links. The version as written asks if you want to remove each tag. After you are comfortable with the clip, there is a comment telling you to take out the skip if you don’t want confirmation.
;*** Effort by Don Passenger
;*** don a-t htmlfixit d-o-t com
;*** discuss things live in chat at http://htmlfixit.com
;*** based on work by Larry and Jody and maybe Wayne
;*******************************************************
;delete any a href tags
;start at top of document
^!Jump Doc_Start
;### initialize everything
;look forwards to find the starting < :Loop
^!Find "<" TIS
;exit if find fails
^!IfError Finish
^!SetScreenUpdate Off
^!ClearVariables
;### %TAG% will be empty if cursor is not inside a tag.
^!Set %TAG%="^$GetHtmlTag(TRUE)$"
^!IfTrue ^$IsEmpty(^%TAG%)$ NotTag
;### So we found a tag. What tag is it?
^!Set %TAGNAME%="^$GetHtmlTagName("^%TAG%";UPPERCASE)$"
;react if it is an A tag (opening or closing)
^!If "/A" = "^%TAGNAME%" HREF
^!If "A" = "^%TAGNAME%" HREF ELSE NotTag
:HREF
^!Select HTMLTAG
;delete following line if you want it to not ask before deleting
^!Skip Leave this tag in:^%nl%^$GetSelection$^%nl%^%nl%(Press Ctrl+Alt and click button to abort.)^%nl%
^!Keyboard DELETE
^!Goto Loop
:NotTag
^!Jump Select_End
^!Goto Loop
;### clean up and go home
:Finish
^!SetScreenUpdate On
^!ClearVariables
;line 46 if you have all lines unrapped (including blank lines)
Remove Table Tags from XHTML or HTML Document
June 9, 2005 on 2:04 am | In Generic Clips | No CommentsThis clip should remove all table, tr, and td tags from a document including end tags.
;*** Effort by Don Passenger
;*** don a-t htmlfixit d-o-t com
;*** discuss things live in chat at http://htmlfixit.com
;*******************************************************
;clip strips html table tags from entire document
;go to start of document
^!Jump Doc_Start
;loop to check each tag to see if it is a table tag
:Loop
;find next tag start
^!Find "< " TIS
;quit when no more tags
^!IfError Finish
^!ClearVariables
;### %TAG% will be empty if cursor is not inside a tag.
;determine if tag and get the name of the tag
;if not table tag cycle to next via NotTag subroutine
^!Set %TAG%="^$GetHtmlTag(TRUE)$"
^!IfTrue ^$IsEmpty(^%TAG%)$ NotTag
^!Set %TAGNAME%="^$GetHtmlTagName("^%TAG%";UPPERCASE)$"
;I think there are six tags in tables so
;these six options are tested and tag deleted if match
^!If "TABLE" = "^%TAGNAME%" Table
^!If "TD" = "^%TAGNAME%" Table
^!If "TR" = "^%TAGNAME%" Table
^!If "/TABLE" = "^%TAGNAME%" Table
^!If "/TD" = "^%TAGNAME%" Table
^!If "/TR" = "^%TAGNAME%" Table
^!Goto NotTag
:NotTag
^!Jump Select_End
^!Goto Loop
;if TABLE tag delete it
:Table
;delete the tag
;could just replace it with a
;or something like that if you wish
^!Keyboard DELETE
^!Goto NotTag
:Finish
^!Info [C]finished with this file
^!Goto End
;line 51 including all blanks and comments>
Splitting a Line of Text on Spaces
June 3, 2005 on 5:53 pm | In Generic Clips, Notetab Clips | No CommentsYou can create an array by dividing on a set character. In this example I split on spaces per the request of the writer.
;*** Effort by Don Passenger
;*** don a-t htmlfixit d-o-t com
;*** discuss things live in chat at http://htmlfixit.com
;*******************************************************
;I assume each line in the file is this 9 field data format:
;"title 1 some text title 2 other text 567034"
;start at the top (assuming whole file)
^!Jump Doc_Start
;set list delimiter to space and get array elements
^!SetListDelimiter " "
:Loop
;get the row we are in
^!Set %row%="^$GetRow$"
;select the current line where cursor resides
;this will select the entire line from prior
;line feed to this one
^!Select Paragraph
;delimited array set by splitting line on spaces
^!SetArray %delimited_data%=^$GetSelection$
^!Set %indx%=1
:Loop_Display
;display each array element
^!Info Row is: ^%row% ^PElement ^%indx% is ^%delimited_data^%indx%%
;check if we have used all elements in current row
;compare current index number to number of elements
;in the array using delimited_data0 - which stores
;the number of elements in an array
^!If ^%indx% = ^%delimited_data0% Next_Line
^!Inc %indx%
^!Goto Loop_Display
;move to next line and then continue
:Next_Line
;go to next line
^!Jump Select_End
;loop again if there are more rows
^!If ^%row% = ^$GetLinecount$ END ELSE Loop
Significant points in this clip:
1. use of the ^!SetArray command to divide on a preset delimiter (in this case a space)
2. use of the special 0 element in the array to determine how many elements are in the array
3. use of the line: “^!If ^%row% = ^$GetLinecount$ END ELSE Loop” to test if we are at the end of our file
testing if you are at the end of a file is a common necessity in notetab clips.
Clip to Remove Set Number of Columns from Each Line in a File
February 9, 2005 on 10:55 pm | In Generic Clips | No Comments;by don at htmlfixit dot com on 2/9/2005
^!Info This clip will x columns from all lines in a file
^!Set %remove%=^?{Enter Columns to Remove=_1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23}
^!Jump Doc_Start
^!SelectTo ^$GetLinecount$:^$Calc(^%remove%+1)$
^!Continue Is the last line selected to the proper column?
^!ToolBar Delete Block
^!Info [C]Done
I think this will work well. The select in Notetab is a little funky because it appears to highlight all, but then this Toolbar command only works on some columns, so to test if it got the right stuff, you need to carefully look at the last line. I added a continue there so you can stop it. The other two info’s are really surplus and can be discarded.
Open Files in Irfanview
December 1, 2004 on 5:15 pm | In General, Generic Clips | No CommentsA reader on the YahooGroups Clips List was wondering how to open files in Irfanview via a NoteTab Clip. I proposed the following two solutions:
Continue reading Open Files in Irfanview…
HTML: Remove & and replace with &
November 29, 2004 on 4:06 am | In Generic Clips | No CommentsIt is often necessary to replace the & character with the entity & to get validated (x)html. This clip will replace all appropriate ampersands excluding those that are part of defined character entities.
Continue reading HTML: Remove & and replace with &…
Remove Lines with Numbers
November 29, 2004 on 4:02 am | In Generic Clips | No CommentsThis regex loop will remove all lines that contain only numbers on them. There is a quirk so that it won’t work correctly on one pass, so I loop it to get it to work correctly.
; by don at htmlfixit.com ; removes all numbers on a line ; for some reason the regex doesn't ; work right, so I repeat to ; get all instances -- odd but ; sometimes it goes that way :Loop ^!Replace "^\d+\n" >> "" ATIWRS ^!IfError END ^!Jump 1 ^!GoTo Loop
Sample input:
this that 12 567 a324 -you 15 x374
Sample output:
this that a324 -you x374
Keywords: regex, regular expression, remove, numbers, line, loop, repeat
Find Sub-string in Longer String
November 29, 2004 on 3:45 am | In General, Generic Clips | No CommentsThese may display very funny for some people because of the use of the pre html tag. Continue reading Find Sub-string in Longer String…
Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^