473,386 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Favorite Scripting shortcuts

What's your favorite bit of "short-cut" code that you use?

One of my favorite shortcuts I'll use when coding a page is to create a sub
along the lines of the following:

Sub Print(myText)
Response.Write myText & vbcrlf
End Sub

And then I use Print instead of Response.Write thru my code.

I do this for several reasons:

A) I'm an old-skool coder, and I started coding back in the days when you
wrote to the screen with "PRINT"

B) It's shorter than doing Response.Write [insert string here] & vbcrlf for
every instance where you want to write to the client.

C) It's easier to use for debug purposes: If for example I want to do a
time-trace to see where a slow-down is occuring, I'll change the code to
Response.Write "<!--" & Now() & "-->" & myText

D) If I want to adapt a particular snippet of code for client-side, I'll
usually just have to copy/paste (along with minor changes), and include the
Print sub, except with Response.Write changed to Document.Write.

Jul 19 '05 #1
9 1517
> B) It's shorter than doing Response.Write [insert string here] & vbcrlf
for
every instance where you want to write to the client.
I've used rw() in the past.
C) It's easier to use for debug purposes: If for example I want to do a
time-trace to see where a slow-down is occuring, I'll change the code to
Response.Write "<!--" & Now() & "-->" & myText


Wow. If you call this function a lot of times in a single page, the mere
writing out of the now() data is going to skew your results. ;-)

A
Jul 19 '05 #2
"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in news:Osb
$A***********@TK2MSFTNGP12.phx.gbl:
C) It's easier to use for debug purposes: If for example I want to do a
time-trace to see where a slow-down is occuring, I'll change the code to
Response.Write "<!--" & Now() & "-->" & myText


Wow. If you call this function a lot of times in a single page, the mere
writing out of the now() data is going to skew your results. ;-)


hehe, it was an example. And probably a poor one at that. ;-)

I think the main reason I do it is for comfort-level... I'm so used to
PRINT "My Data" that I find myself wanting to revert to it.

Now if only I could figure out how to ? "My Data" I'd be a happy man!
Jul 19 '05 #3
This line helps a lot (the main code "library" I use on most every page:

<!--#include file="include/jpsutility.asp"-->

Best regards,
J. Paul Schmidt, Freelance ASP Web Designer
http://www.Bullschmidt.com
ASP Designer Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #4
On Tue, 22 Jun 2004 10:36:25 -0700, Scott McNair
<sc**********@sfmco.takethispartout.com> wrote:
What's your favorite bit of "short-cut" code that you use?

One of my favorite shortcuts I'll use when coding a page is to create a sub
along the lines of the following:

Sub Print(myText)
Response.Write myText & vbcrlf
End Sub

And then I use Print instead of Response.Write thru my code.


Why don't you just use <%= %> instead?

I can't stand those people who do:

Response.Write ...
Response.Write ...
Response.Write ...

rather than
Response.Write ... &_
... &_
...

Worse are the ones who do

strSQL = ...
strSQL = strSQL & ...
strSQL = strSQL & ...
etc

rather than

strSQL = ... &_
... &_
...

Talk about slow cuts.

Jul 19 '05 #5
> Why don't you just use <%= %> instead?

Uh, because that's much less readable, in most cases.
I can't stand those people who do:


Did you mean "I can't stand when people do:"?

A
Jul 19 '05 #6
Zenobia <6.**********@spamgourmet.com> wrote in
news:ti********************************@4ax.com:
Why don't you just use <%= %> instead?
Well, for one - I may not be breaking out of HTML. Quite a bit of my
code is actually very server-intensive, and I would be going out of my
way to <%=%> things...

'Code goes here
'Code goes here
'Code goes here
%>
<%=NewValue%>
<%
'Code goes here
'Code goes here
[...]
....not to mention the (admittedly minor) overhead that %><%="words"%><%
causes by switching out of, then into, then out of, then into server-
processing.
I can't stand those people who do:

Response.Write ...
Response.Write ...


[snip]

I agree.
Jul 19 '05 #7
> ...not to mention the (admittedly minor) overhead that %><%="words"%><%
causes by switching out of, then into, then out of, then into server-
processing.


This is minor in IIS 4.0 and below.

In IIS 5.0 and above, the parser is MUCH smarter and you will be very
hard-pressed to find ANY overhead difference.

--
http://www.aspfaq.com/
(Reverse address to reply.)
Jul 19 '05 #8
On Wed, 23 Jun 2004 10:34:29 -0400, "Aaron [SQL Server MVP]"
<te*****@dnartreb.noraa> wrote:
Why don't you just use <%= %> instead?


Uh, because that's much less readable, in most cases.


In many cases <%= %> is more readable than using Response.Write
because with <%= %> one tends to embed the server output within
HTML but when using Response.Write people I know tend to output
HTML with variables, which means doubling quotes, for instance.
Making the code less readable...
I can't stand those people who do:


Did you mean "I can't stand when people do:"?


Yes. Well spotted. One has to work with them even if they
completely ignore you when you tell them why they shouldn't do
it.

Jul 19 '05 #9
Bullschmidt <pa**@bullschmidt.com-nospam> wrote in
news:eq**************@TK2MSFTNGP12.phx.gbl:
This line helps a lot (the main code "library" I use on most every
page:

<!--#include file="include/jpsutility.asp"-->


Yeah, at work we maintain a "miscfunctions.asp" page which is
more-or-less the same thing. =) Really nice place to dump all those
frequently-used functions.

A couple of functions I've got in mine:

Function DevNotes(Note)
If Dev=True Then Response.Write "<b>" & Now() & ":</b> " &_
Note & "<br>" : Response.Flush
End Function

(I usually put a line at the top of my code while developing it, "Dev =
True". Once it goes into production, I change the line to something
like "If Request("Dev") = "asdfg" Then Dev = True". We use it to
display SQL statements, key steps in a process, etc.)

Function Break(MyText)
Response.Write MyText
Response.End
End Function

[Another development-level function. If something squirrelly is
happening at a particular point, I'll put error-trapping to the effect
of 'If xyz Then Break("XYZ Happened")']

And needless to say, the aforementioned Print function is in there too.
Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Randy Given | last post by:
What is your favorite Java development environment? What others have you tried? What are some pros and cons of each? Thanks!
34
by: nobody | last post by:
This article is posted at the request of C.W. Yang who asked me to detail my opinion of Lisp, and for the benefit of people like him, who may find themselves intrigued by this language. The...
2
by: beliavsky | last post by:
Linux Journal annually polls its readers on questions such as their favorite programming language. In the 2005 poll, Python is 2nd, its highest ranking ever. Below are the results by year. I wish...
1
by: G$ | last post by:
I'm trying to write some C# code to call the Windows Scripting Host (WSH) to create shortcuts, but I'm having problems. First, I referenced Windows Script Host Object Model. Then, I wrote the...
0
by: GeorgeF | last post by:
How can I conditionally deploy shortcuts to my application? I have created a custom installer dialog box to give my users the option of creating desktop/start menu shortcuts, but the shortcuts do...
4
by: Dave Taylor | last post by:
I have a VB.NET program that does flowsheet simulation for mineral processing. I would like the user to be able to write some rules for nodes within the flowsheet, ideally something like VBScript...
5
by: PAzevedo | last post by:
With ToolStripMenuItem objects i created a 'Tools' menu and from that menu droped an Item to which i assigned a ShortcutKey of 'Keys.Control | Keys.E', and the shortcut doesn't work. This...
331
by: Xah Lee | last post by:
http://xahlee.org/emacs/modernization.html ] The Modernization of Emacs ---------------------------------------- THE PROBLEM Emacs is a great editor. It is perhaps the most powerful and...
0
by: Steve Holden | last post by:
The Linux Journal readers apparently suffer the same ambiguity as the rest of us when it comes to defining what the difference between a scripting language and a programming language. They do,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.