I added an Around the Net section to my blog. The idea is to showcase articles from various places around the internet. Mostly this is unvetted and almost like my own personal front page of the internet. I currently have some stuff from Archeology Now and Atlas Obscura. I might add some bloggers that I follow over time as well.
I think another section of stuff that I have actually read might be nice as well but not sure how much upkeep that will take and there really isn't a utility for that. This page is starting to be more me focused than for an audience which is fine.
I'm pretty happy with the code to parse the RSS as it ended up being quite short and uses the MATCH statement and MATCHFIELD function. Parsing XML with BASIC was surprising pleasent and straightforward.
FEED.URL = 'https://www.archaeology.org/feed'
*
CMD = 'curl -s ' : FEED.URL
*
EXECUTE \SH -c "\ : CMD : \"\ CAPTURING FEED.DATA
*
ITEM.PATTERN = "0x'<item>'0X'</item>'0X"
*
LOOP UNTIL NOT(FEED.DATA MATCHES ITEM.PATTERN) DO
ITEM = MATCHFIELD(FEED.DATA,ITEM.PATTERN,3)
FEED.DATA = MATCHFIELD(FEED.DATA,ITEM.PATTERN,1)
*
TITLE.PATTERN = "0x'<title>'0x'</title>'0x"
TITLE = MATCHFIELD(ITEM,TITLE.PATTERN,3)
*
IF TITLE = '' THEN CONTINUE
*
LINK.PATTERN = "0x'<link>'0x'</link>'0x"
LINK = MATCHFIELD(ITEM,LINK.PATTERN,3)
*
PUB.DATE.PATTERN = "0x'<pubDate>'0x'</pubDate>'0x"
PUB.DATE = MATCHFIELD(ITEM,PUB.DATE.PATTERN,3)
*
PRINT TITLE, LINK
REPEAT
*
STOP
*
* END OF PROGRAM
*
END
*
The most curious thing here was that UniVerse seems to find the last match first. This means that I needed to pick off the first part and iterate over it looking for the next match.
The idea of the MATCHES and MATCHFIELD is to loop and cut the string into the various pieces. I want to capture part of the match and then update the new search string with the remaining pieces to do the next match.
I want to write a longer article about the MATCHES and MATCHFIELD functions in BASIC as I think they are interesting and I haven't run into them in other languages. They are like a rudimentary regex but not as powerful. I also want to write a tool that will tell you the indices of the different parts of the pattern. I can piece it together if I got slowly but I think having something like crontab guru would be nice for the patterns.