Monday, June 02, 2014

A Question on One of Rabbi Natan Slifkin's Ten Questions

His questions, and their answers, appeared to be aimed at two types of people. Those who say, "Evolution! Ptui!" and those who say "Evolution, duh." Since those two positions are extremes, I'd like to raise a problem with his second question/answer from a position which lies between those extremes. I hope R' Slifkin will do me the honor of replying to this question.

2) Why should schools accommodate evolution? Isn’t it just a theory, not a fact?

Here's my problem. He refers to "common ancestry" as "the fact of evolution", as opposed to "the theory of evolution", which refers to the way in which evolution happens. In other words, gradual mutations.

He states:

One is common ancestry, the concept that all animal life arose
from a common ancestor – simple organisms gave rise to fish, fish to
amphibians, amphibians to reptiles, reptiles to birds and mammals
(without getting into how that could have happened). This is
supported by a wealth of converging evidence along with testable
predictions. Common ancestry is considered by all scientists (except
certain deeply religious ones) to be as well-established as many other
historical facts, and is thus often referred to as “the fact of
evolution.” It is of immense benefit in understanding the natural world –
for example, it tells us why whales and bats share anatomical
similarities with mammals, despite their superficial resemblance to fish
and birds.

This troubles me. I'm aware that there are similarities between species, and that it can be useful to draw conclusions from those similarities. But I don't understand how it is a "fact" that bats and whales and chimpanzees have a common ancestor. I understand how that has explanatory power, but not how it is necessary. In other words, it's similar to the difference between correlation and causation. The idea of common ancestry correlates with what we see, but it isn't the only possible idea that correlates with it.

By way of analogy, let's consider the musical concept of "variations on a theme". In variations on a theme, a composer may create numerous compositions which are all... well, variations on a single theme. If one were to discover these variations at different times, one might conclude that they started with one version, and that each successive version was a modification, one further step away from the original each time. Kabbalists as well were known to write variant forms of a given text for different purposes. The most famous case is probably the hymn Yedid Nefesh, which is sung in many congregations on Erev Shabbat. For centuries, the words of this hymn were known, though there were minor variants. In the mid-20th century, what has been determined to be a manuscript of the hymn in the author's own hand was discovered, and since then, a small number of congregations have switched to the substantially different version. It has been theorized, however, that the author deliberately created a version of the hymn with fewer explicit Kabbalistic images for general consumption.

Creating similar but different versions of a single thing, to serve different purposes, is a hallmark of creative action. Why do the anatomical similarities between different mammals require a common ancestor? Even assuming that one species can evolve into another (something which has been demonstrated in the lab), how can it be established as "fact" that this is indeed the process by which all species came to be? The idea of extrapolating such a process back to a point source seems like an extraordinary claim.

Of course, if one begins from the premise that God cannot have had a hand in it, Occam's Razor would lead us to the extrapolation to a point source. It is certainly the simplest way to explain things in the absence of any intelligent design. But how does that qualify it as "fact"?

Given two books by the same author, I can draw many conclusions about one from the other, particularly because I know they share an author. Similarly, it's useful to do the same with biology. But in terms of logic, I don't see how "the fact of evolution" follows as a necessity from the physical evidence.

(I expect that those who find mere mention of evolution anathema will consider this article nearly as bad, and that those who consider belief in the theory of evolution b'chol dikdukeha u-prateha to be the sine qua non of civilized thinking people will see this as a sign that I'm a primitive ignoramus. Everyone is entitled to their opinions. However, I have moderation enabled here, and I won't be allowing gratuitously obnoxious comments through.)

Sunday, April 27, 2014

David Benkof's Op-Ed

On April 23, 2014, David Benkof wrote an Op-Ed in The Times of Israel called "Orthodox, celibate, gay and that's OK". In this piece, Benkof makes some good points and some horrendous ones, and I felt that it deserved a response. One Facebook friend of mine posted it with the caveat that it was "above his pay grade." It is not above mine, so I've taken it upon myself to respond.

(Responses to my response are welcome, with the usual caveat that if they're obnoxious, I'll make them public.)

Benkof starts off by noting the dearth of reasoned responses to the issues of being frum and gay, and attributes this to traditionalists who "would rather not discuss sexuality at all, are afraid of sounding bigoted, or simply have never heard cogent answers to such claims." It's about time someone else pointed this out, so kudos to Benkof on that count.

He goes over his past as a public gay figure and his return to Orthodox Judaism. He omits some of his more egregious attacks on gay people and gay causes since then, but that may be out of shame or a desire not to muddle the message of this particular essay. I would refer interested readers to his Wikipedia page for more information.

Benkof mentions some of the terribly dishonest ways that well meaning Jews, in various Jewish groups, have attempted to deal with the obvious fact that anal sex between men is, and will always be, a major prohibition in Judaism, on the same level as incest and adultery. I'm not going to go over those cases of rabbinic malpractice, because Benkof did so himself, and admirably.

(Incidentally, if this sounds like a puff piece on Benkof's piece, you should know better than to jump to conclusions. I simply believe that good should be lauded every bit as much as bad should be condemned. That'll come.)

Now... I have to confess that in one area, I can only talk about what I've heard from friends who are both frum and gay, simply because I can't know what it's like to be a gay man. And even there, I know that what one gay man feels needn't be what another feels.

Benkof goes into the wide variety of views, from barely-Orthodox-ish folks like Shmuely Yanklowitz to causes celebre like Orthodox-ordained Steve Greenberg to shtartker yidden like Rabbi Chaim Rapoport, claiming that demanding celibacy is entirely inhuman.

And here's the first place I have to take issue with Benkof. Before starting on his personal story, Benkof gives the following caveat:

For the purposes of this essay, “celibate” means no sexual contact at all between any two people. For the most part, lesbian relations are not discussed in this piece since that issue is halachically distinct, although some of the ideas below also apply to women.

I disagree with his lumping all intimate contact into a single category. It's as wrongheaded as lumping all eating into a single category because some food is non-kosher. Yes, we avoid foods that are non-kosher from the Torah as much as we do foods that are non-kosher based on Rabbinic rules, but we maintain the distinction, and in this case, the distinction may make a bigger difference than it does with kashrut.

I have friends who are gay and frum and who refrain from engaging in anal sex. I have friends who are gay and not frum (not even Jewish) who find the idea of anal sex repellant and refrain from it, not because of any rules, but because they simply don't want to do it.

Are there gay men who honestly can't live sane lives without that one act? As I said above, I can't possibly know the answer to that, but I have serious doubts, and accounts by gay male friends to support my doubts.

But Benkof's conflation of mishkav zachor (anal sex between men) with all other physical intimacy is wrong on another level. When Orthodox Jews are challenged regarding the way they treat gay people, as opposed to, say, any other category of sin (which is a wrongheaded comparison, but a common one), the virtually ubiquitous response is that it needs to be treated more harshly because the Torah terms it a to'evah, or "abomination". But that term is only applied to that one act. Absent that act, the question becomes, again, why treat gay people so terribly when people who don't conform to Jewish law or communal norms in other ways are not treated that way?

But onward...

Benkof lists the four primary arguments made by Jews objecting to his call for celibacy. (1) That it can't be done, (2) that it's theologically untenable, (3) that other mitzvot trump celibacy, and (4) celibacy demands have terrible consequences. I agree with him that (1) and (2) are nonsensical, and I think it's fairly obvious that (3) has no place in any Orthodox Jewish discourse.

Which leaves us with (4): the consequences of demanding celibacy. I'll return to (4) further on, but as Benkof should be aware, there's another objection: (5) It's unnecessary.

What I mean by that is that it should be unnecessary for any frum gay Jew to "come out" as celibate. If a Jew is known by their actions to be Torah observant, and has not denied Torah miSinai or made public claims that things prohibited by halakha are permitted, all they should need to do is say, "I keep Jewish law. My being gay is not an excuse for any exceptions to my faithfulness to Jewish law.." If that means, in the person's view and the view of the person's halakhic authority, that they need to be celibate, fine. If it means something else, also fine. It isn't for David Benkof to decree that only one halakhic view is legitimate. And it is wholly inappropriate for anyone to take "I am gay" as a declaration of intent to violate halakha, which can only be overridden by a declaration of celibacy.

But, I've heard claimed by many, you can't expect people to reasonably assume that two people of the same sex in a committed relationship aren't having sex. Benkof says something of the sort himself:

Some Orthodox gays insist that coming out is not a proclamation of
sexual activity; it’s rather an affirmation of their internal makeups.
But Judaism forbids marit ayin – even giving a hint of violating halacha. So coming out of the closet without clarifying that one is celibate really isn’t kosher.

This is wrong on several levels. I'll discuss a few of them. According to an article on WebMD.com, "Almost all Americans have sex before marrying" and "such behavior is the norm in the U.S. and has been for the past 50 years." Presumably, then, by Benkof's standards, anyone hailing from the United States should have to publically proclaim that they do not engage in premarital sex, and do not accept it as halakhically legitimate, otherwise, there is a problem of marit ayin. And that it is entirely fair and correct to make such assumption about Americans.

And speaking generally, it probably is a fair and correct assumption to make about Americans. In general. But of course, being an Orthodox Jew takes us out of the general. So we don't make such an assumption about American Orthodox Jews, because the commitment to Jewish law overrides membership in the United States. Similarly, I don't actually disagree with the premise that gay people, in general, don't limit their sexual practice due to what they perceive as imposed standards. But when it comes to Orthodox Jews who are gay, the general rule doesn't apply.

And of course, Benkof slips in his dictum that only a public affirmation of celibacy is halakhically sufficient to take oneself out of the generality. Presumably, because he has done that. By setting the bar to precisely what he has done, despite the fact that it is not the only halakhic view (admittedly, it is by far the most common one, but it is not the only one), he turns his entire essay into a self-serving, self-promoting attack on frum gay Jews.

Let's get back to (4), though. And let's leave aside the question of sex for a moment. Human beings have a natural propensity to form intimate relationships. Emotionally intimate. This is as true for gay people as it is for straight people. Far from it being an indication that they have cast off halakhic limitations, two frum Jews of the same sex in a relationship can help one another in the same way they'd help one another when it comes to other aspects of Jewish law.

Is it possible for people to live a solitary, loveless existence? Probably. Yes, it probably increases the likelihood of mental and emotional difficulties, and may make it more likely that such a person could commit suicide. And while Benkof poo-poos the suicide issue by casting it as so much emotional blackmail, statistics bear out a causal relationship between rejection and aloneness for gay people on the one hand, and a greatly increased rate of suicide on the other.

But is it possible? Let's say for the moment that it is. Is it necessary? Is it a goal worth striving for? I would say that it isn't. People who are gay are... gay. It isn't going to change. It's a facet of life. And so is the need for intimate companionship. A year or so ago, this video was going around the internet. The woman in it talks about having lost her husband 6 years earlier, and how much she misses him. And that it isn't about the sex. It's about the person. Benkof seems not to understand the difference.

It isn't his first. He is the author of Jewish History in
Conflict: A Study of the Major Discrepancy Between Rabbinic and
Conventional Chronology (Jason Aronson, 1997), in which he attempts to make a case against the Jewish view of history.

I wanted to address some of his claims here, in the spirit of שתיקה כהודאה, just to make sure his claims don't go uncontested.

I find it interesting that First
speaks of "the simplest understanding of Ezra 4:6 without quoting the
verse itself, and the surrounding verses. In this way, the reader is
left with the choice of either looking it up himself, or taking First's
word for it. So in order to make this easier for at least readers of
Areivim, let's have a look.

7 And in the days of Artaxerxes wrote Bishlam,
Mithredath, Tabeel, and the rest of his companions, unto Artaxerxes
king of Persia; and the writing of the letter was written in the
Aramaic character, and set forth in the Aramaic tongue. {P}

First appears to be using the same oversimplistic reading methodology
used by advocates of the documentary hypothesis when he says that "The
simplest understanding of Ezra 4:6 and its surrounding verses is that
Achashverosh is the Persian king who reigned after the Daryavesh who
rebuilt
the Temple, but before Artachshasta." In fact, the opposite is true.

The enemies of the Jews hired counselors against us from the time of
Cyrus through the time of Darius the Persian. Which means that they stopped hiring those counselors after the time of Darius the
Persian. So if those counselors wrote accusations against us during
the reign of Ahasuerus, Ahasuerus must have reigned between Cyrus and
Darius.

Of course, it's possible that it was the enemies themselves who wrote
those accusations, and not the counselors, but if so, it's an entirely
different subject, and the text first tells us about counselors who
were hired from the time of Cyrus to the time of Darius, and then talks
about accusations which were written. If that's so, there's no
chronological order involved. It would be like me saying: "Ron Paul
served as a Congressman from Bill Clinton's presidency through Barack
Obama's presidency. Paul ran for president in 2008." That's
completely true. But reading it the way First is reading Ezra would
suggest that he ran for president after Obama's presidency. Which is
factually incorrect.

That's far from the only problem with First's analysis. He attributes
his contra-Chazal view of Persian history to a number of Jewish
scholars purely on the basis of them agreeing that the name
Achashveirosh and the name Xerxes are the same. But that's a truism
that I don't think anyone disagrees with. It doesn't mean that
Achashveirosh/Xerxes reigned after Bayit Sheni was built. It's been
many years since I read R' Avigdor Miller's history series, but I'm
willing to assert that he would have been greatly offended by First's
suggestion that he agreed with the Greek version of history and
disagreed with the Jewish one.

Tuesday, December 18, 2012

The Objective Money Amendment

The following is a proposed amendment to the Constitution of the United States. Its purpose is to:

Retire the National Debt

Ensure a proper supply of money for use in trade and necessary government expenditures

Prevent the government from incurring new debt

Forgive mortgage and revolving credit loans on a one-time basis so that the United States is no longer a culture of debt

Prevent the government from inflating the money supply in a way detrimental to the people of the United States

Objective Money Amendment

Section 1
The power of Congress to issue money shall not be delegated, except to the United States Treasury.

Section 2
The power of Congress to borrow money on the credit of the United States, as specified in Article I, Section 8 of the Constitution, is hereby repealed.

Section 3
The practice of fractional reserve banking is hereby outlawed. The creation of money by lending against deposits shall be deemed counterfeiting unless the amount of the deposits is decreased by the amount being lent.

Section 4
Money shall be issued initially in an amount necessary to fulfull the following:

To purchase back all debt instruments previously issued by the United States

To retire all mortgage and revolving credit loans taken by non-corporate persons and/or partnerships up until one year prior to the adoption of this amendment

To lend banks, at no interest, sufficient money to raise their reserves to 100% after the retirement of mortgage and revolving credit loans, such loans to be repaid upon the bank closing.

To replace, dollar for dollar, any Federal Reserve Notes in circulation at the time of adoption of this amendment.

The quantity of money issued shall be increased or decreased each year by a per annum fraction of the growth or shrinkage of the population of the United States between the previous two census results.

Section 5
Congress shall have the power to legislate a temporary issue of money in order to pay for such projects as it sees fit. Such temporary issue must be legislated separately from all other temporary issues or other legislation, and must include an expiration date. Money so issued shall be destroyed by the expiration date.

Section 6
Money issued by the United States shall be legal tender for all debts and payment of taxes.

Section 7
The right of individuals or groups to issue money in units other than the United States dollar shall not be infringed. Such money shall not be legal tender for payment of taxes.

Saturday, October 27, 2012

Atlas Shrugged -- For Adults Only

The other day, I was talking to my partner about Atlas Shrugged at the dinner table, and my 12 year old daughter asked what it was. I told her it's a book by Ayn Rand, and that she can't read it until she's 21.

My partner stared at me and asked why. After all, I'm an Objectivist. I think Rand's philosophy is incredibly important. So why would I bar my daughter from reading it until she's an adult?

I've felt this way for at least a decade, but given the President's comments about Ayn Rand's books being something you'd pick up as a 17-18 year old feeling misunderstood, and then get rid of once you realized that thinking only about yourself wasn't enough, I thought it would be worthwhile to explain why kids shouldn't read Atlas Shrugged.

The thing is, Obama is right. In a way. Let me explain that.

I didn't read Atlas Shrugged until I was 33 years old. In fact, other than Anthem, which I may have read in passing in high school, I never read anything of Rand's until I was 32, and I started with her essays. Maybe I'll post about how and why I got into those at a later date. But as someone who didn't get into Rand's philosophy as a kid, it took me a while to realize that for the vast majority of people, reading it as a teenager is almost inevitably going to create the opposite effect that Rand had in mind.

There's a common misconception that Objectivism is about being selfish and grasping and greedy. It's an understandable misunderstanding. After all, Rand wrote a book of essays called The Virtue of Selfishness. She spoke against altruism and in favor of selfishness. The thing is, though, that in Rand's writing, those are "terms of art". A term of art, or jargon, is a word that's used a specific way in a specific field, regardless of how it's used colloquially. In politics, to "depose" means to remove a leader. In law, to "depose" means to have someone give a deposition. In medicine, an "ugly" infection is one that doesn't respond well to antibiotics.

We're all familiar with groups "reclaiming" perogative words. "Queer" was an insult when I was growing up, and it still is for a lot of people. Yet to the younger generation of GLBT teens, "queer" is simply how they identify. Rand used the term "selfish" to mean acting to further ones long term and global well being, given the understanding that we are not alone in the world, and that what I do to others can be done to me as well. There is no other way to describe that in a single world, so far as I'm aware, than selfishness. Or if we allow a modifier, "rational selfishness".

But Rand failed. She failed to communicate this in a way that would be clear enough to get past the negative connotations of selfishness as meaning a blind, grasping devotion to ones short term desires, paying no attention to the world around us. Even expanding the term to "rational selfishness" didn't work, because people understood "rational" to mean "cold and unemotional" and concluded that "rational selfishness" meant cold, hard, unemotional, uncaring selfishness. Like a robot that lacks all empathy.

But adolescents are a different story. Adolescence is a time when we are detaching ourselves from our role as dependent children, and learning to stand on our own, personally empowered. When I was 17, I remember one evening during an argument with my father, exclaiming, "You're a person, and I'm a person. Why should you have any more right to decide than I do!" And I was absolutely convinced of my righteousness. Two years later, when my younger brother was 17, I heard him say virtually the exact same thing. I looked at my father and said, "I'm so sorry, Dad. And I wish there was some way I could explain it to him." But I knew there wasn't. You can't explain that to an adolescent. They have to learn to grow up and realize that the world doesn't revolve around them.

Which is one of the reasons why a lot of adolescents love Atlas Shrugged. They miss the bigger picture, and only pick up on the message that they shouldn't have to sacrifice themselves for others. Which is a good message, but they conflate it with their irrational selfishness. Their self-centered, almost solipsistic view of the world. And when they do grow up, as most of them do, they jettison Objectivism, thinking that it's part and parcel of the adolescent mindset they no longer need.

And that's why Obama said what he did. It's absolutely true that 17 and 18 year olds who are feeling misunderstood, and whose self is feeling threatened would pick up Atlas Shrugged and see it as a vindication of what they're feeling. And it's absolutely true that someone like that reading the book would, in the vast majority of cases, throw it away once they grow up and realize that we're all in this together, so to speak.

And that's why I won't let my daughter read the book. Because it takes a certain amount of maturity to understand that the kind of altruism that says doing for others is always more moral than doing for oneself is evil and anti-human, but that benevolence and empathy are vitally important virtues. The vice of altruism always leads to bad results in the long run, even if it may seem beneficial in the short term. Because giving requires a recipient. And if receiving is a bad thing, there's always going to be someone bad and wretched. More than that, you're always going to need poor people, because without them, you can never be virtuous. It's an ugly world that raises altruism up as the highest virtue.

Perhaps we need to find another term to reflect what Rand called "selfishness". The battle to reclaim that word was lost before it even started. All it does now is feed into the ignorance of the left.

Tuesday, October 16, 2012

Morethodoxy or Lessodoxy?

Zev Farber, one of the participants in the "Morethodoxy" blog, a branch of the Open-Orthodox/JOFA/Partnership-Minyan/YCT/Maharat/Post-Orthodox growth on the far left edge of the Orthodox community, has posted an article in which he takes issue, not with those who refuse to allow women to participate in shul, but with those who permit women to participate in shul, only not as the norm. He feels that the default should be equal participation, limited only, if absolutely necessary, by whatever halakhic restrictions he hasn't found a way around. Yet.

One of the things, possibly the main thing, which separates Orthodox Judaism from the various heterodox movements is that we never, ever, raise any -ism above the Torah. That means that if Zionism conflicts with the Torah (which is rarely does, in my opinion), we go with the Torah. If feminism conflicts with the Torah, we go with the Torah. If capitalism conflicts with the Torah, we go with the Torah. If socialism conflicts with the Torah.

More than this. We don't start from an -ism as our baseline and interpret the Torah through it. We don't force the Torah into this -ism or that -ism.

Zev Farber asks, "Why is it that the synagogue automatically assumes that the baseline should be no participation and that women need to put themselves out there?" And the answer is simple. Because there is a difference in obligation. And the Torah makes distinctions. And Orthodox Jews don't blur those, certainly not because of an -ism.

If Zev Farber doesn't daven with a minyan, he's remiss. If I don't daven with a minyan, I'm not. It's that simple.

Judaism isn't egalitarian. Egalitarianism is just another foreign -ism that American culture is so in love with that many ostensibly Orthodox Jews find themselves committed to it ideologically. And so long as they leave it outside of Judaism, that's fine. Once they bring it into Judaism, it's not fine at all.

I belong to a Women's Tefillah Group. Why? I grew up Conservative. I have a personal connection to doing things that are outside of the Torah norm. I make no apologies for it. I think Women's Tefillah Groups are good for BTs and giyorot. They rarely continue into the next generation, because girls who grow up frum don't feel the need for them. Unless their mothers go out of their way to tell them how "oppressed" they are otherwise.

The idea of women's participation in shul came about for a very simple reason. In the heterodox movements, Judaism is all about shul. Judaism is one thing that exists in the framework of their lives. In shul. At life cycle events. To an Orthodox Jew, life is something that happens in the context of the Torah. Not the other way around. It's a matter of what's the ikkar and what's the tafel. And because Judaism is the tafel in the heterodox movements (as well as in the minds of many left-wing modern Orthodox Jews), shul is the focus of Judaism. So being less participatory there stings. Whereas to real Orthodox Jews, who recognize that Judaism isn't just our religion, but rather our life, shul isn't at all the center of Judaism for us.

Zev Farber's entire thesis fails before he even gets started. Because his complaint isn't even with the details. I belong to a Young Israel, so my Women's Tefillah Group can't meet there (it's in the YI bylaws). That's a detail. But for Zev Farber, that's not something to struggle with -- he wants to revamp Judaism entirely, so that the default is that we all participate equally in shul.

Some Jews grow up Orthodox. Or become Orthodox. And some of these Orthodox Jews move away from Judaism, opting for something that suits them more, philosophically. Conservative. Reform. Reconstructionist. Renewal. Humanist. Some of those who move away philosophically also move away in practice. Alice Shalvi, the noted feminist, resisted this for years. Philosophically, she had left Orthodox Judaism behind her. But she felt an emotional tie to it. She didn't want to acknowledge the move that she'd already made inside. Eventually, she "came out" as Conservative, but it was sort of like Ellen Degeneris coming out as gay. It was only a surprise to those who weren't paying attention.

I hope that Zev Farber and other members of this blog will learn from Alice Shalvi. I hope they will stop trying to drag Judaism off the derekh, and if they feel so strongly opposed to it philosophically, just go.

Monday, June 11, 2012

A Programming Odyssey

Most of you can probably skip this post. It isn't about politics or Judaism or Israel or economics or any of the usual things I talk about. This is about a battle I waged last week with a piece of code. A battle which, as yet, has not been won.

Anyone who feels like they'd like to chime in is welcome to. Those of you who feel, like a coworker of mine, that I'm tilting at windmills unnecessarily, well, all I can say is that I don't like to lose.

The goal

Okay, the company I work for has a customer. They want a web app where, among other things, they can generate a report each month to be sent to their customers. And they want these reports, once generated, to be static. Unchangable. Initially, they wanted them to be made into PDFs. Generating the reports in HTML is child's play. Nothing to it at all. But then things started getting wonky...

PDF

I should give you some background. We have a Microsoft-only shop. Our apps live in IIS (the Windows webserver) and I don't have to worry about cross-browser issues, because our customers know they have to use IE. Of course, we do have compatibility issues with different versions of IE, but so far, these are manageable.

Being all Microsoft, we of course use .NET. ASP.NET, in this case. And it turns out there's a free .NET component that you can use to manipulate and create PDF files, called itextsharp.

So I delved into the world of creating documents in itextsharp, and was able to convert my report to PDF. Which was create. The creation happened on the server, so I could save the PDF to a file share, note its location in a SQL Server table, and all's well with the world.

Private Sub MakePDF(ByVal reporttype As String) Dim path As String = "some file path" Dim urlpath As String = "the url version of that path" Dim reportdate As Date = #date# Dim pdfname As String = reportdate.ToString("yyyy_MM_") + reporttype + ".pdf" If Not IO.Directory.Exists(path) Then 'if the path doesn't exist, create it IO.Directory.CreateDirectory(path) End If If IO.File.Exists(path + pdfname) Then 'if the file already exists, delete it. 'this should never be called if it's been finalized. IO.File.Delete(path + pdfname) End If Try Utils.ConvertHTMLToPDF(strHTMLTable, path + pdfname) Catch ex As Exception strAlert = "PDF Create Failed: " + ex.Message Exit Sub End Try If Not IO.File.Exists(path + pdfname) Then 'if the file wasn't created for whatever reason strAlert = "PDF Create Failed" Else 'update the location and existence of the file in the database End IfEnd Sub

That could have been it. Except that the PDF didn't format well. The report table was tabular and all, but it wasn't all that readable. I suggested to our customer that it might be better to do it as a protected Excel spreadsheet. I often export reports for them to Excel, and protecting them is simple. And formatting is fairly straightforward. They okayed this, and that's where the fun really started.

Excel

For those of you who have ever wanted to export a table from HTML to Excel, it's really simple. You just select the table, copy, and paste it into the spreadsheet. I've seen people around the interwebs trying to create tables in Excel cell-by-cell, and they can't understand why it's so slow. You just send the innerHTML of the table to the clipboard (simple in Javascript), and paste it using Excel's object model.

(I was going to post the code here, but it's a little long. If anyone is interested, I'll be able to supply it.)

The problem here is that all of this is done on the client. Once I got this working, I needed to find a way to get the report back to the server. And that, it turns out, is a nightmare.

File Browser control

I figured the simplest thing to do would be to put a hidden file browser button on the page, and use that to post the file back to the server. I use these all the time:

But for security reasons, you can't set the file in this control programmatically. Which I suppose is a good thing, usually. You don't want a web page to be able to pillage your files, right? Except that in this case, I made the file, so the security didn't make a lot of sense. Still, I get why there aren't exceptions for situations like mine.

FileCopy

Well, since all of this is on an intranet, where everything is connected on a single network, why not just copy the file from the client to the server? Answer: because the average user doesn't have access to the file server. Thank God. But maybe there's a way for me to do a filecopy, sending credentials through? And indeed, there is. In theory. Here's the code I used:

'Find out next available drive letter strDrive = "" For i = 67 to 90 strDrive = Chr(i)& ":" If fso.DriveExists(strDrive) Then Else Exit For End If Next

if strDrive = "" then alert("Could not Access network drive") exit function end if

oNet.MapNetworkDrive strDrive, savefolder, False, UserName, Password

fso.CopyFile localfile, strDrive + "\\" + filename, true

Set fso = Nothing

oNet.RemoveNetworkDrive strDrive, True, False

Set oNet = Nothingend function

Nice, right? The WScript.Network thing lets me map a drive using enhanced credentials. Which means I should be able to copy the file and then get rid of the mapped drive. Oh, and this is in VBScript, btw. All the examples I saw of WScript were, and mixing scripts in IE is no biggie, so I did it that way. And stuck it in a .vbs file so that users wouldn't be able to grab the credentials just by viewing the page source.

The problem turned out to be that yes, I can map the drive with those credentials. But the filecopy failed anyway. For no apparent reason. And I was unable to unmap the drive afterwards, too. In the code, I mean. I could do it manually through Windows Explorer.

So, so, so close. At this point, my only option seems to be to save the data that makes up the report into a database table and regenerate the report each time anyone needs to see it. The biggest downside to that is that no one can see the report without me coding something. If they were files on a file share, there'd be no coding necessary. But... time constraints being what they are, I don't seem to have much of a choice. My coworker (slash-boss) wrote this to me:

I hope you aren't like the US in Afghanistan-- that you've put too much into the effort to back out now. Becuase I don't see why data can't be put in a table and never touched... I say we should stick with what works-- even if you get around MS security with this file copy, it could very well quit working at some point with an OS update or security policy change.

This feels an awful lot like surrender, which is not something I like to do. So I may keep working on it in my own time.