Cockadoodle Doo, Yo

Well. I’ma crow a little bit today.

Yesterday, I was ridin’ high coming into the day. I’ve been blowing away the tasks assigned to me. Sure, it takes me months to solve the riddles sometimes. Sure, I do some mumbles and humbles and get beet-red when I have to say “I don’t know  how” in staff meetings with my boss and associates. But every macro I’ve had to tackle I’ve knocked out of the park.

Even when I thought I didn’t.

So late last week, the ATR coordinator asked me to look at a problem she’s had with one of the screens she uses. I told you about this – it printed the serial numbers over and over, remember that? Well, I hit that one out of the park too.

Then I came back today and decided I’d have another run at getting the email attachment problem solved. You might not remember this one. Back in the summer we decided it might be a nice feature to be able to attach files to our outgoing email messages to divisions and customers. Sounds easy, right?

Yeah, not so much, it turns out.

Well, for the last – what? six, seven months? more? – I’ve been banging my head against that particular wall. This even came into play before Appmageddon. But I couldn’t do anything with it. I just…couldn’t get it to work.

Yesterday, I opened up that page again and took another look. I saw something I didn’t notice before. Well…that’s not exactly right. I guess I just didn’t see it this way before.

I tweaked. I tested. I tweaked again. Tested again. And you know what?

Shut the front door – I got the email. AND the attachment!

VICTORY! VICTORY FOR ZIIIIIIIMMM! Praise the Lord Most High, for clearly this came from His inspiration. Know how I know that?

Because I have no idea what’s different now that it works when it didn’t before. NONE.

There were a couple of routines I saw, and I recognized a bit of what they might be doing. I changed the references a touch, thinking, “Well, maybe it should be this instead of that.” And voila! Success. Sweet, gratifying success.

OH, I danced! I danced like Snoopy dances, and at my weight, that’s quite the spectacle.

I ran to my boss and bragged, “Hey, I beat your man GW again! I got the email attachment thing to work! I did it!”

I chatted and beamed a moment, and then went back to my desk. I deployed the solution to the production web server. Then, I had a meeting to go to with my boss and his staff members. During that meeting, the ATR Coordinator had to leave for the “Kaizen Event” I mentioned to you before. The meeting broke maybe an hour later, and when I got back to my desk, guess what?

I had an email from the ATR Coordinator.

She said, “We have issues with the intranet. I can’t send any notifications to the divisions. It’s giving an ‘Empty Path’ error now.”

My sphincter tightened so fast and so severely I gained an inch in height. You couldn’t have driven a toothpick in it with a ten-pound sledge.

Okay, I thought, stay calm. The error indicates the message can’t be sent without an attachment now. So…so…what’s that mean?!

OHGODWHATDOESTHATMEANFORTHELOVEOFCHRISTHELPME!!!

Or, you know, something like that.

So, this was like, two o’clock. I putzed around with other solutions but they weren’t going well. Finally, it hit me like a ton of bricks.

Before, we could send messages but not attachments. Now we can send attachments but not messages without them. Solution – put both scripts on the page and have them execute at different times.

Okay, how do I do that?

The way I did it was simple, and a little stupid, but then, so is this entire way of working with this crap, in my view. I simply put two buttons on the page. The first one calls the original script, and sends the message without attachments. The second one uses a modified script, takes the object in the file box (which I added), and embeds it as an object. (No, I didn’t come up with that code; neither did my predecessor though. He borrowed it from the Internet, so we BOTH stand on the shoulders of geniuses to do what we do. So there.)

Then the script sends the message through the local email client running on the machine being used.

Done!

And tested. And tested. And tested. It sends through the Internet, sends through the intranet, and sends the attachments faithfully.

Score!

Appmageddon just got a little less scary.

Now, back to the NAFTA database macro. I have to automate it. And I did; problem is, the automation through the database itself is ssssslllllllllooooooowwwwww. So I did it through an Excel spreadsheet instead, but now have to figure out how to get the two together. Two-step process, maybe? I’ll see.

But the process took something like half an hour through the database. The exact same code, copied and pasted to the workbook’s code editor directly from the database’s editor, runs in eight seconds from the workbook.

Uh…this is a no-brainer.

So, I’ll see what happens there later. For today, I have month-end reporting to do, weekly reporting to do, and I’m still way behind on some of these things.

See ya next time.

-jdt-

Advertisements

Good Friday

I have to confess, I’ve no idea why today is called “Good Friday.” I’ve wondered that for years. But that’s another post for another blog, for another day, I suppose.

For now, I want to celebrate the joyous Easter coming.

And I have some reason to celebrate. Yesterday at work, I had some cool things happen, and only one bummer thing.

See, on Wednesday I had someone come to me and ask me if I could adjust one of the legacy intranet pages because it showed serial numbers for our return requests from customers. Some of our manufacturing divisions require a serial number before they’ll authorize a return. When we put that data into our system, it’s called up when we do prints of the requests. Long story longer, no matter how many serial numbers you enter, it shows up ten times. And, if you put in more than one, only the first one shows up…ten times.

An interesting conundrum. I found it more interesting when I learned my predecessor had been informed of the matter but never resolved it.

When I looked at the print page, I saw the matter. A loop was the problem.

(Aside: In programming-ese, a “loop” is a block of code which is executed multiple times, so instead of writing the code over and over again, you write it once and instruct the program to do it over and over until a condition is either satisfied or stops being satisfied.)

See, the loop was told to execute ten times. A counter was set to 1, and the loop was set to run until the counter became 11 (incrementing ten times). That same counter was used to extract the index number of the serial number data. So let’s say there are five serial numbers for five units being requested for return. The counter (called “x” in this case) was set to 1, like so: x=1 (complex programming code, eh?) Then the loop was told to run until x=11, like so: Do Until x=11 (wow! Can you handle that technical jargon there?!).

Okay, then the serial numbers were selected by saying “Put the serial numbers in this HTML table cell where the serial number = SN(x).” Then the counter gets incremented by one (“x=x+1”, more super-intense computer code), and the loop repeats. Got it?

So, for some reason (and I’m still not precisely sure why), the code never worked correctly. Instead of getting serial number index “x” like it was supposed to, it got the first one it came to and then repeated that cycle over and over again.

I knew what to do, though. And damned proud of myself I was for knowing! I changed the loop to say, “Do this stuff UNTIL THERE ARE NO MORE SERIAL NUMBERS, regardless of how many there might be.”

This is called a “Do Until” loop. Instead of saying “Do this until the counter is incremented ten times” (and ten wasn’t random; the page in which serial numbers are entered only has slots for ten of them), my code says “Do this until you don’t have any more records in the serial number spot” and then finishes. Got one serial number? It goes through the code once. Got ten? It goes through ten times.  And, should I ever improve the page, if you input 40, you’ll get 40 out.

So I made the alterations and tested the code. It failed. Programming error. I left on Wednesday night feeling pretty dejected and stupid. I woke up a couple of times on Wednesday night – as is my habit, due to bladder requests or thirst or whatever – and every time I did awake, this problem was running through my head. I have no idea how that happens, but it happens occasionally. So when I woke up Thursday, I went to work thinking about the problem and still didn’t have any clue why my loop didn’t work and his did.

Feeling sort of inferior and humbled, I looked at the problem again. And I noticed something… a missing piece of the code. When I altered the loop, I forgot to tell the computer code to advance to the next record, if there is one, and do it again. When I added the simple line “recordset.movenext” to the code just before I told it to loop through again, BAM! Success! The page loaded perfectly and ran flawlessly, and ONLY shows the existing serial numbers once!

And now, it shows ALL the serial numbers, not just the first one over and over.

VICTORY!

Okay, great, on I go. I spent the better part of last week working on two things: a NAFTA database macro which would automatically perform some tasks rather than having to perform those tasks manually, and a page which shows the number of times one particular customer is changing their orders. (The sales team for that customer, and the quality representatives for that customer, will be in our location for what’s called a “Kaizen Event” to improve quality communications. We’re using it as a chance to provide ammunition to our sales team to get the customer under control. Long story, but it’s something we have to do; their people can’t keep up with the changes being made, how are we supposed to do so?)

Well, I got the new web page built using the new, “better” technology, and tested it repeatedly. Then I set it aside. I finished it about 4:30PM last Friday, and figured I’d deploy it this week. Well, I sorta forgot, so when it came up again, I scrambled to get it uploaded to the web server.

And it bombed.

For the next two hours, I cursed, banged my desk, pulled my rapidly-graying hair, and stormed to the bathroom to fume. The test server simply won’t provide me with the error messages and I can’t remember what I did in production to get it to happen. So, flustered, I deployed the new application to production to see if I could find the problem.

I almost screamed it was so simple. So, I quick-fixed the issue and BAM! Success!

VICTORY! …and I copied the fixed version to the test server as a back-up and they’re working fine. The requestor is very excited to arm our sales team with this data next week, and I’m pleased it worked as intended. Phew! Close one!

Finally, time to turn my attention to the NAFTA database macro.

*Sigh*

I still don’t know what’s wrong with it. So, two wins and a loss. In the grand scheme of things, I suppose that’s not too bad.

There’s always next week.

I hope you have a happy and joyous Easter if you’re celebrating, and I’ll see you Monday or thereabout.

God bless you.

-jdt-

Friday Frolic

Well, Friday has finally gotten here! Not a moment too soon, and perhaps many days too late, but it’s here just the same.

I’ve been banging my head over an interesting problem with attachments and emailing through Lotus Notes from an intranet site. The one I support is largely built with ASP, which was from about 1996 or so, and replaced with ASP.NET in 2002 and after. The site I support was built in 2004, but hey, I didn’t get to pick the technology. My predecessor also had tied hands over what he could spend, probably, and how fast it had to happen.

So it’s my ball of fun now. I have a page which faithfully sends Lotus Notes email through the local machine’s Notes session, but the user can’t attach files to those emails. So I’m struggling to find out how that happens.

I’ve found a lot of information about how to do it, but none of the scripts I located seemed to work for my situation. Or I simply couldn’t figure out how they worked, which was bothering me no end. I can’t support something if I don’t get it.

So I thought about moving this to ASP.NET, but there’s a lot involved in that. I could move just this one page, like I’ve done before, but so far I’m not finding anything I can use “out of the box” (and I really need that, at this point).

So after a week of dizzying highs because of great success with VBA, it’s a hard crash back to reality with ASP.NET/VB.NET. I’m just not there with my skills. I’m just…not quite. Again.

But the weekend is upon us and I’m going to relax and enjoy it. I’ve got to get back to my videos eventually, but really need to think about what I need to see and how to approach my learning to best give me the results I need.

What are you going to do this weekend? Any big plans?

If you’re a Kindle user and are just sitting around reading, all my books are either on sale or free. You can catch ‘em here if you’re interested. (I ‘m no responsible for the Ch’od Action Figure, though. Sorry, WIGSF.)

Have a great weekend, y’all!

-jdt-

Friday Flurry

Not much happening, so I guess it’s not a “flurry”, per se, but there are a few things happening.

For one thing, I found an issue with our data which has been plaguing my ASP classic pages for a few months. Every once in a while, one of the intranet pages would fail to find a customer someone looked for, or wouldn’t locate a customer to populate the pages with their orders for us, or something like that. For the ATR Coordinator, the problem manifested a couple months back when she tried to enter an ATR for a customer and couldn’t because the pages couldn’t locate the customer.

She asked me to add them to the database so she could process the request. When I tried, I found they were already in the database. But…then what gives? Why wouldn’t the customer come up in a search?

So the new IT manager for the business group with which we share the space – who is a full-on .NET developer and knows his stuff – was brought in (by the ATR Coordinator without my consent or knowledge) and offered to help. I accepted eagerly. He sat down and started working through the page methodically and when he saw the issue, he was stumped too.

Then he did something magical – he added a tiny bit of code to make the query see two different kinds of values from the database, and voila! The customer was found! But… there was a cost.

The customers each showed up two, sometimes three, times in the search results. Complete with duplicated IDs, contacts, phone numbers – you name it.

But hey! At least it worked, right?

So we’ve been like that for a bit. Then, a similar problem cropped up in a completely different area of the intranet. But the data was the same. I’ve been crawling through it for a couple of days now trying to fix the problem, but to no avail, until yesterday.

I discovered the database contained not one, but two types of data for a single field, when the field didn’t have an entry. There’s either a NULL value, which is a database standard, or a zero-length string, which is a series of characters. For example, the word “pie” is a string of length three; i.e., three characters long. Of course, “213” is also a string of length three, IF you consider the characters (digits) as characters instead of numbers. So, that’s a string, and in this particular field of this particular database, there are values stored as either a string (when there’s an entry) or a NULL (when there isn’t) or a zero-length string.

But the bizarre part? The zero-length string is the only value the web page searches the database for. So if the customer record had a null in that field, it wasn’t found. Because nothing, empty strings (zero-length strings) and nulls are all different things in computer world.

Why the old admin chose to look only for the zero-length string is anyone’s business. I can’t ask him, and there’s a story behind that, but that’s for another day. Or blog. Or blogger. But that’s what I’ve got and that’s what I found by poring over the page, the data, and crawling through line by line, cleaning up the code on that page.

Then, I used Visual Studio’s query utility to quiz the database and get all the data in that table. That’s when I found the mixed values in this particular field, which is used as one of the criteria for the query on the ASP page. Mystery solved. Now, how to fix it?

There are some 40K records in that database. I’m NOT going to walk through it by hand and change the values. I can set the default value to be NULL on the table design in Microsoft Access (which is the database we use for some reason), but that only works for new records. So I have to update the table with either one or the other. I think the best choice is NULL, but then, I’m not a dba.

Next, I lost some weight. Rolled the middle digit down. But I gained that back and then some, so I’m miffed about that.

And I’m still not able to find time to write anything. Between the programming classes and the work and everything else, there just doesn’t seem to be time during the week anymore. I can’t figure it out. Up until recently I seemed to be able to get more done when I get home at night. I suspect we have an issue with increased TV time, but can’t be sure. And I can’t stop the family from enjoying themselves just because I can’t.

Hope you all have a good weekend. I plan to!

Next week I start MVC training, I think.

-jdt-

Another Notch in the Belt

Well, I think I’ve finally found my groove on this computer programming video learning thing. I’ve figured out how to take notes in a way which works well for my mind, and allows me to keep up with the video much better. No more trying to “take notes” (read: “transcribe”) by pausing the video and re-wording what I see on the on-screen slide.

I’m doing it faster and retaining it longer, and last week, I put some stuff I learned to work for the first time. I not only remembered the processes but some of the details too. (Not all of them, of course, but I’m still new at this and didn’t exactly “study” beforehand.

What this all means is, I finished another class. By the time you read this I’ll be moving on to the next one, trying to decide what that will be. So go me!

The downside to all this is, I’m slacking off a bit on the viewing. I’ve been tired and drained every night when I get home and slept in on Saturday. While I love what I’ve got working for me right now, in terms of the note-taking (I never did learn how to do this in school, btw), it has become a two-step process for me. I have to take the raw, rough notes and then make them legible and clear in their permanent location elsewhere. I’m not sure how I feel about that and I wondered whether it would create problems with recall for me to go too long between viewing sessions. So I deliberately waited a few days as a test.

I found as I transcribed and cleaned-up the notes, my recall was pretty good. I knew what everything meant, and actually expanded on some things a bit as I worked through them. And the best part is, I covered more ground more quickly with fewer pages. I love it.

So now, to apply.

I’m excited to tackle the next phase of my learning – MVC. I think I’ve described that one to you already, but if not, don’t worry. A horrible and boring review probably isn’t far off as I work through Appmageddon and see where it takes me. I have to hurry up and get it done, though, so prayers are appreciated.

On and up!

-jdt-