SHARE
Facebook X Pinterest WhatsApp

Simple ASP Application Page 2

Jul 20, 2010
ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More



Here’s the code for Enhanced.ASP

The function neg_to_red takes a string and
returns a string with around all the
negative numbers. This function assumes the maximum length of a line
on the report is 132 and negative sign is trailing on negative
numbers ex 12.23- Feel free to use the function if you ever find a
need for it.

function neg_to_red(line)

pos = 2

last_end = 0

Do While pos

chr1 = Mid(Line, pos, 1)

chr2 = Mid(Line, (pos – 1), 1)

chr3 = Mid(Line, (pos + 1), 1)

If ((chr1 = “-“) And (chr3 = ” “) And (IsNumeric(chr2))) then

        pnt = pos – 1

       finished = 0

       Do While finished = 0

             
If ptr

                
finished = 1

            
Else

           
If Mid(Line, pnt, 1) = ” ” Then

                 
hold_line = “

                
build_line = build_line & Mid(Line, last_end + 1, (pnt –
last_end))

                
build_line = build_line & hold_line

                
build_line = build_line & Mid(Line, pnt + 1, (pos – (pnt)))

                
build_line = build_line & “

                
last_end = pos

                
finished = 1

           
Else

                   
pnt = pnt – 1

                  
If pnt = 1 Then

                       
hold_line = “

                       
build_line = build_line & Mid(Line, last_end + 1, (pnt –
last_end + 1))

                       
build_line = build_line & hold_line

                       
build_line = build_line & Mid(Line, pnt + 1, (pos – (pnt)))

                        
build_line = build_line & “”

                       
last_end = pos

                       
finished = 1

                   
End If

             
End If

           End
If

         Loop

         End
If

    pos = pos +
1

Loop

build_line = build_line & Mid(Line, (last_end + 1), pos –
(last_end + 1))

neg_to_red = build_line

end function

%>

Here is the code that reads and displays the
text file

RESPONSE.WRITE “”

‘CHR(34) is a double quote the line
ends up being   written as

FTP_VIRTUAL_PATH =
“/REPORTS”

FTP_PATH =
SERVER.MAPPATH(FTP_VIRTUAL_PATH)
‘ Get
the physical path to the reports directory

SET O_FSO =
CREATEOBJECT(“SCRIPTING.FILESYSTEMOBJECT”)

IN_FILE = REQUEST (“E_FILE”)
       
‘Get the file name posted to the
page

FILE_NAME = FTP_PATH &
IN_FILE

SET INSTREAM = FILEOBJECT.OPENTEXTFILE
( FILE_NAME, 1, FALSE, FALSE) 
‘Open
the text file for input

RESPONSE.WRITE “

"
             

‘Use the HTML tag

meaning the
following code is preformatted(keeps the spacing)

WHILE NOT
INSTREAM.ATENDOFSTREAM    
‘Proccess until end of file reached

   IN_LINE =
INSTREAM.READLINE

   IF INSTR (IN_LINE, “-“)
THEN
           
‘ If there is a negative sign in the line
call the function neg_to_red

        
RESPONSE.WRITE     NEG_TO_RED(IN_LINE) &

”  

   ELSE
                                                        
‘ Else we just write back the
line

        
RESPONSE.WRITE      IN_LINE &

  END IF

WEND

%>

Recommended for you...

What Is a Container? Understanding Containerization
What Is a Print Server? | How It Works and What It Does
Nisar Ahmad
Dec 8, 2023
What Is a Network Policy Server (NPS)? | Essential Guide
Virtual Servers vs. Physical Servers: Comparison and Use Cases
Ray Fernandez
Nov 14, 2023
ServerWatch Logo

ServerWatch is a top resource on servers. Explore the latest news, reviews and guides for server administrators now.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.