Mr Chimp’s First Law of Slashdot
April 2nd, 2012If the title of an article on slashdot.org is a question then, unless grammatically incorrect*, it can be answered with some variation of “no”, i.e. “no, not yet” or “no, not necessarily”.
For example:
Does Higher Health Care Spending Lead To Better Patient Outcome?
Do E-Readers Spell the Demise Of Traditional Schooling?
*(i.e. Does not apply to “Ask Slashdot” posts such as “what is the best…”)
MapBasic Directories and Paths
March 28th, 2012MapBasic provides a few functions for getting part of a path. Here’s how you use them to do some common things with the output as comments:
Open Table "C:\folder\file.tab" as MyTable
Dim path as string
path = TableInfo(MyTable, TAB_INFO_TABFILE) ' C:\folder\file.tab
print PathToFileName$(path) ' file.tab
print PathToDirectory$(path) ' C:\folder\
print PathToTableName$(path) ' file
print TempFileName$("") ' C:\Users\MrChimp\AppData\Local\Temp\MIPRO\MapInfo.Application_1900\~MAP0004.TMP
Language
March 26th, 201268.54% of visitors to this site are located in the United Kingdom.
75.28% of users have their language set to EN-US.
So either a lot of you have your computer’s language set wrong or there is a disproportionate amount of American visitors living in the UK.
“For each record in table” and Layer Numbers
March 14th, 2012For each record in table
Sometimes in MapInfo/MapBasic you want to do something to each record in a table in turn. If you’re anything like me you don’t have to it very often so when it comes to doing it you’ve forgotten how you did it the last time. There are a number of ways to do this depending on your situation but here’s a simple method using a Do While loop. You may require a different method, for example if you are using a progress bar. I’ll try and include some other methods at some point.
Do While loop method
Fetch First From MyTable Do While Not EOT(MyTable) Print MyTable.Col1 Fetch Next From MyTable Loop
Getting a layer number
Each layer in a MapInfo mapper window has a layer number. This is to identify individual layers in a mapper and is different from the table’s ID number. Here is a function to get the layer number from a given layer name and window number. The FrontWindow() part is just an example of how to get a window ID and call the function.
Function GetLayerNum(ByVal LayerName as String, ByVal WindowNum as Integer)
For i = 1 To Numlayers
If WindowInfo(WindowNum, WIN_INFO_NAME) = LayerName Then
GetlayerNum = x
Exit Function
End If
Next
End Function
Dim layer_num as Integer
GetLayerNum("MyTableName", FrontWindow())
Pointless Batch File Exercise
January 25th, 2012Create a new text file.
Name it “implode.bat”.
Open it in a text editor.
Type the following:
DEL "%~f0"
Save the file and close your text editor.
Locate the file in your browser.
Double click on it.
Haha! Now you’ll have to start again. Sucker.
New Tools for the Indecisive TV Viewer
January 23rd, 2012More news from Chimpcom.
Not long ago I added the reddwarf command which displayed the name of a random episode, to help you pick on to watch.
I briefly considered creating a complex algorithm to take into account which episodes you’d already seen. I could also implement ratings – per-user and cloud-sourced average – and weight the probabilities based on that.
I may well do that but not quite yet.
In the meantime I’ve generalised the command and given it a new name: choose. “Why?” you ask, “what does that achieve?” Well…
Now, if I type “choose reddwarf” (the series’ name must be one word at the moment…I’m working on that) you will get a random episode name, along with some extra info.
But the bonus is you can now type “choose 24″ or “choose bigbangtheory” or “choose fastshow” or any one of over 6000 other TV shows.
Of course, even though it’s not case-sensitive and there is some fuzziness to the searching, the names aren’t going to be quite how you type them on your first go. To make this a bit more straight-forward I’ve added the shows command.
For a full list of shows type “shows”. To search for a show name, type e.g. “shows dwarf” to find the Red Dwarf. Only one search word is currently allowed.
Handy hint: if you only get one result when you use the shows command, you can use your search term with the choose command. E.g. “shows dwarf” finds only Red Dwarf. Therefore “choose dwarf” would pick an episode of Red Dwarf. However “choose red” would pick a random episode from the first show that matches the word “red” – whatever that is – which probably isn’t what you want.
Listings are provided by epguides.com/.
Next on the list is tab-completion. Watch this space.
Pointless Function is Pointless
December 14th, 2011Syntax UnitAbbr$( unit_name ) unit_name is a string representing a standard MapInfo Professional unit name (for example, “km”). Return Value String expression, representing an abbreviated unit name (for example, “km”)
So you put in “km” and you get back “km”. How did I survive without this function?!
[Ok, so I think it's supposed to be for converting the English version of a unit to another language. They could have used a better example though.]
Knife Fork Spoon – The Full Story
December 5th, 2011One three-panel comic. How far can I take the puns. In script for for no very good reason.
INT. ROOM – NIGHT
TONY lies on the sofa flipping a coin and trying to catch it on his nose. FRANK enters with a harassed expression.
FRANK
Dave’s been knifed!
TONY leaps up, throws the coin through the window and kicks the cat at the fridge.
TONY
Knifed?! That’s forking terrible!
FRANK stares in disbelief.
TONY
[looking concerned]
What, too spoon?
FRANK shakes his head as if to say “what the fuck is wrong with you”.
FRANK
What the fuck is wrong with you?
TONY
Well, what happened? Did they mug him?
FRANK strides away, and launches into the story]
FRANK
Yeah, they just… Wait.
He stops and turns around. TONY’s grinning like a cunt.
FRANK
That was another pun, wasn’t it.
TONY’s smile instantly disappears and he looks concerned.
TONY
No, I just…
[He tails off and sighs in exasperation]
Look, did you call the cups?
FRANK
[starting to lose it]
I’m serious! They almost got me, too!
TONY
Well, were you mugged? You know I always told him you you should just wok away.
FRANK
Do you want me to fucking punch you?
TONY
That’s a whisk I’m willing to take.
FRANK
He’s dead, Tony!
TONY
Oh. Shit! Well…I guess I’ll mark the day on my colander.
FRANK
For fuck’s sake, man-
TONY
Sorry, I’m just…
[he searches for the word]
…bowled over, you know. It’s not a pretty pitcher.
FRANK
Fuck you.
[He storms out]
TONY
Ladle.
PDF Font Embedding
November 14th, 2011I thought that the idea of PDF – standing, as it does, for Portable Document Format and with portable in this context basically meaning that it should be the same under a variety of circumstances – would look the same whenever it is viewed. This is not the case.
I have also recently learned that as well as the original PDF format there are five subsets:
PDF/X – PDF for exchange
PDF/A – PDF for archive
PDF/E – PDF for engineering
PDF/VT – PDF for exchange of variable data and transactional (VT) printing
PDF/UA – PDF for universal access.
There’s also the non-standard PDF/H – PDF for healthcare – which presumably nurses you back to sanity after you’ve been dealing with PDF files.
Most of the time you won’t need to know or care about the above but sometimes you’ll be in a position – as I was last Thursday – when you send your document to the printers and they come back to you saying that the fonts need to be embedded. Which is odd when the only font being used is Arial.
The trick – at least in my case – is to force your PDF exporter to use PDF/X or PDF/A. because /A and /X are designed for exchange and archiving respectively they require fonts to be embedded. This is usually a case of checking a box in your export/print dialogue. Mine is in a section called “Standards” with the label “PDF/A-1b (Acrobat 5.0 Compatible)”. Yours may be slightly different, but just look for PDF/A, PDF/X or ISO Standard.
