473,614 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

is it possible to capture the output of a function in asp?

I have a function that is a few thousand lines of code (I didn't write
it) and I want to capture the output and save it as a variable. This
is very easy to do in php. It would look something like this.
<?php
function myFunc(){
echo "something else"
}

//sent immediately to browser
echo "something"

//start capturing the output
ob_start();

myFunc()

$out = ob_get_clean();
//$out now contains 'something else'
//and 'something else' is never sent to the browser.

?>

Is this possible in ASP? I've searched the net and haven't been able
to find anything.
Jul 22 '05 #1
9 2717
Response.Write Function()

--
'dlbjr
'Pleading sagacious indoctrination!
Jul 22 '05 #2

"Jay Donnell" <ja********@gma il.com> wrote in message
news:9c******** *************** **@posting.goog le.com...
I have a function that is a few thousand lines of code (I didn't write
it) and I want to capture the output and save it as a variable. This
is very easy to do in php. It would look something like this.
<?php
function myFunc(){
echo "something else"
}

//sent immediately to browser
echo "something"

//start capturing the output
ob_start();

myFunc()

$out = ob_get_clean();
//$out now contains 'something else'
//and 'something else' is never sent to the browser.

?>

Is this possible in ASP? I've searched the net and haven't been able
to find anything.


your php function "myFunc()" would be considered a sub in vb because it does
not return a value.

here's a sample vb function:

Private Function SquareTheArg( x as Double) as Double
Return ( x * x)
End Function

***then to use the function***
dblAnswer = SquareTheArg( someVariable)
HTH
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.788 / Virus Database: 533 - Release Date: 11/1/2004
Jul 22 '05 #3
> here's a sample vb function:

Private Function SquareTheArg( x as Double) as Double
Return ( x * x)
End Function

***then to use the function***
dblAnswer = SquareTheArg( someVariable)


OOPS - that was dot-net junk
---retry---

function SquareTheArg( x)
SquareTheArg = x * x
End Function
*****
then to use the function -
resultVar = SquareTheArg( someVariable)
****Or to show the result directly**
<%= SquareTheVar( someVariable) %>

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.788 / Virus Database: 533 - Release Date: 11/1/2004
Jul 22 '05 #4
1. include the file in a separate ASP page that calls the function. get the
new page using xmlhttp (http://www.aspfaq.com/show.asp?id=2173).

2. rewrite the function to return a string containing the output instead of
writing it out directly. The difficulty of this will depend on how the
function is currently written but this would be the "better" approach.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Jay Donnell" <ja********@gma il.com> wrote in message
news:9c******** *************** **@posting.goog le.com...
I have a function that is a few thousand lines of code (I didn't write
it) and I want to capture the output and save it as a variable. This
is very easy to do in php. It would look something like this.
<?php
function myFunc(){
echo "something else"
}

//sent immediately to browser
echo "something"

//start capturing the output
ob_start();

myFunc()

$out = ob_get_clean();
//$out now contains 'something else'
//and 'something else' is never sent to the browser.

?>

Is this possible in ASP? I've searched the net and haven't been able
to find anything.

Jul 22 '05 #5
Ok, I don't think I explained this very well. In php I can have a
function that uses echo(response.w rite) to send data to the browser.
However, I can tell php to buffer it and not send it to the browser.
Then I can grab the data that is in the buffer and put it in a
variable. In my example below the line in myFunc, echo "soemthing
else"; never gets sent to the browser and I put the contents of the
buffer in the variable $out. Basically, I have some asp code with a
very big function. I want to take all the data sent with
Response.Write and the plain html and capture it before it is sent to
the browser. I know that I can do something like

sub mySub
content = content & "some html here
....
end sub

I don't want to do this because the sub is thousands of lines of code
and I don't want to change it all. In asp you can do something like
Response.buffer = true and it will put all the output in a buffer and
send it all at once rather than piecemeal. I want to be able to get at
the data in the buffer before it is sent and stop it from beind sent.
ja********@gmai l.com (Jay Donnell) wrote in message news:<9c******* *************** ***@posting.goo gle.com>...
I have a function that is a few thousand lines of code (I didn't write
it) and I want to capture the output and save it as a variable. This
is very easy to do in php. It would look something like this.
<?php
function myFunc(){
echo "something else"
}

//sent immediately to browser
echo "something"

//start capturing the output
ob_start();

myFunc()

$out = ob_get_clean();
//$out now contains 'something else'
//and 'something else' is never sent to the browser.

?>

Is this possible in ASP? I've searched the net and haven't been able
to find anything.

Jul 22 '05 #6
Jay Donnell wrote:
...I want to take all the data sent with Response.Write
and the plain html and capture it before it is sent to
the browser...

...I want to be able to get at the data in the buffer
before it is sent and stop it from beind sent...


Which one? Do you want to stop it or capture it?

I'm not sure you can accomplish what you want without modifying the
function. By all is not lost -- you can probably construct a suitable
search/replace for Response.Write( ) in your function.

For example, if the ASP scripting language is JScript, you could add this to
the beginning of your function...

var out = { value:"", add:function(x) {this.value+=x} }

....then search for "Response.Write (" and replace with "output.add (". At the
end, Response.Write( out.value), conditionally of course.

It's trickier if VBScript, since the parentheses are optional with
Response.Write( ), and it may be inconsistently coded.
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 22 '05 #7
With response.buffer =true you can buffer the data and you can discard it if
you don't want to send it. However, you cannot access data in the buffer any
way that I know of.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Jay Donnell" <ja********@gma il.com> wrote in message
news:9c******** *************** ***@posting.goo gle.com...
Ok, I don't think I explained this very well. In php I can have a
function that uses echo(response.w rite) to send data to the browser.
However, I can tell php to buffer it and not send it to the browser.
Then I can grab the data that is in the buffer and put it in a
variable. In my example below the line in myFunc, echo "soemthing
else"; never gets sent to the browser and I put the contents of the
buffer in the variable $out. Basically, I have some asp code with a
very big function. I want to take all the data sent with
Response.Write and the plain html and capture it before it is sent to
the browser. I know that I can do something like

sub mySub
content = content & "some html here
...
end sub

I don't want to do this because the sub is thousands of lines of code
and I don't want to change it all. In asp you can do something like
Response.buffer = true and it will put all the output in a buffer and
send it all at once rather than piecemeal. I want to be able to get at
the data in the buffer before it is sent and stop it from beind sent.
ja********@gmai l.com (Jay Donnell) wrote in message

news:<9c******* *************** ***@posting.goo gle.com>...
I have a function that is a few thousand lines of code (I didn't write
it) and I want to capture the output and save it as a variable. This
is very easy to do in php. It would look something like this.
<?php
function myFunc(){
echo "something else"
}

//sent immediately to browser
echo "something"

//start capturing the output
ob_start();

myFunc()

$out = ob_get_clean();
//$out now contains 'something else'
//and 'something else' is never sent to the browser.

?>

Is this possible in ASP? I've searched the net and haven't been able
to find anything.

Jul 22 '05 #8
"Mark Schupp" <no****@nospam. com> wrote in message news:<eG******* *******@TK2MSFT NGP15.phx.gbl>. ..
1. include the file in a separate ASP page that calls the function. get the
new page using xmlhttp (http://www.aspfaq.com/show.asp?id=2173).
Thanks for the link. This seems like it might work well.
2. rewrite the function to return a string containing the output instead of
writing it out directly. The difficulty of this will depend on how the
function is currently written but this would be the "better" approach.


The reason I don't want to do this is that the function is literally
3000+ lines of code with html mixed in with the asp. Hopefully the
xmlhttp will work.
Jul 22 '05 #9
xmlhttp worked great. It isn't as flexible as the php buffer functions
like ob_start but it worked well for what I needed. Thanks
1. include the file in a separate ASP page that calls the function. get the
new page using xmlhttp (http://www.aspfaq.com/show.asp?id=2173).

Jul 22 '05 #10

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

Similar topics

5
2042
by: steve | last post by:
Hi, In my script (phpnuke), whenever there is access to database, there is this line of code: message_die(GENERAL_ERROR, ’some error msg’, ’’, __LINE__, __FILE__, $sql); Is there a more elegant way of reporting line number besides putting this line everywhere I access db. I want to just write a function, which also globally knows about the current line number(?) and in case
5
2130
by: Aeon Twilight | last post by:
REFERENCE: http://us4.php.net/manual/en/function.include.php Example 16-7. include() through HTTP Example 16-10. include() and the return() statement -------------------- return.php -------------------- <?php
2
3282
by: Salad | last post by:
It's been years since I captured printer output, basically I've forgotten how to do it. Can you refresh my brain and let me know how it's done if it can be done in Access? I don't want the output from a report per-se...I am looking at the output that would be sent to a printer with all the print codes and instead of going to a printer going to a file. A basic text file may be only a few hundred bytes in size but the text file, sent to...
8
1900
by: Daniel | last post by:
Hi, Does anyone know if it is possible to put an aspx page inside of another? OR run an aspx page and capture the output as a string and then write this out to a page.... So for example say you have a page that takes an id number as a query string and displays different things based on that id number. If you were able to loop through running the aspx pages with id=100, id=200,
5
7165
by: Muffin | last post by:
I am trying to capture the out put of a command line program. Let say ping or maybe better yet nslookup. I would like to launch and then capture all the output , redirect it I guess to a string variable or something. I know how to start it , but not how to capture it. Nslookup I realize can be started interactively, which is to some degree what I may need to do as I am discovering that there is no easy way to query DNS svr records with...
2
1510
by: Brian Simmons | last post by:
Hi, Long story short: I've got a website built, and we moved it over to the production server, which is an SSL-required (https://...) server. A third party component that I'm using makes use of an <iframe>. Unfortunately they set the SRC attribute to "". This causes Internet Explorer to display a message box dialog warning about this page contains non-secure and secure items, do you wish to display the non-secure items, Y/N?
2
3093
by: jdbartlett | last post by:
I'm trying to capture output from a command line utility (XMLSec), but only get an empty result. If I call the script from the command line, I see XMLSec's output, but I can't seem to capture it! My PHP installation is working correctly and captures other command line output just fine, XMLSec is the only exception I've found. I've also tried a couple of other systems to confirm this behavior. Capture methods I've tried include:
13
1955
by: Jim Langston | last post by:
I had asked this in comp.lang.c++ with out any answers that would actually work, so I'm hoping someone here may know a way. I am calling C library functions that want to output to stdout. I need to capture this to memory for use internally inside the program without modifying the library calls that actually do the output. This is for the GraphViz libraries and it is the output of dot that I'm actually trying to capture. I have...
5
3155
by: vasilis | last post by:
I have a list box in a site with which I capture a selected value with the onChange event using the capture_value() function (code listed below). This function passes 2 arguments, i.e., 'str' which is the selected list box value and 'passed_url' which is a passed url for running a php script (which contains some url query parameters, e.g. 'somescript.php?var1=value1&var2=value2&var3=value3'). The capture_value() function actually sends a...
0
8182
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8579
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8279
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7093
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6088
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5540
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4052
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1425
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.