# Simple ASP Application Page 2

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 =

IF INSTR (IN_LINE, “-“)
THEN

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

%>