Why the asp code fail? - asp-classic

HeaderStr = HeaderStr & "<link href="""&HB_ManageFolder&"/Include/ASBox/ASBox.css"" rel=""stylesheet"" type=""text/css"">"&vbcrlf
But if I change &HB_ManageFolder& to & HB_ManageFolder & it will work.
Why?

&H starts a hexadecimal number

I don't really know VBScript (which you are probably using with ASP) but as far as I know, it's quite similar to VBA.
And I know this issue from VBA: if you build strings with "&" and you don't leave blanks in between, VBA won't compile until you put the blanks in.
Probably it's the same issue here.
So, you just always have to use " & " instead of "&" and it will work.

Related

Format to allow ASP Classic <% %> tags inside of a FileSystem object Writeline command

I have a script I am building that creates ASP Classic pages from form input.
I am using the file object to create the asp file. It is working as intended, however I am slightly perplexed how to embed ASP CLASSIC code into the string. The open tag works like this:
fname.WriteLine"<% DIM GENERIC_VAR"
This displays in the file properly, however the use of the close tag doesn't seem to want to work. Even my IDE is indicating a formatting issue. Usually in the instances I need to replace a " (double quote) a ' (single quote) will work, but in this case I get compile errors (Unterminated string constant) or the file doesn't create the line as expected. I know about doubling up "" but so far haven't had any luck. Thanks.
Side note as an example, I just need to be able to print this into the line of the file:
fname.WriteLine"%>"
openasp = "<"
openasp = openasp & "% "
closeasp = " %"
closeasp = closeasp & ">"
Set up the ASP tags like above.
Then Wrap them in line as needed for example:
fname.WriteLine openasp & "DIM VAR_NAME" & closeasp

Propper working with arrays and variables

Good morning all together!
I'm quite new to this language and I got a question about arrays. Normally I'm working with Python, so for me it is really something new, especially with arrays many things I could easily do before are not working anymore.
My problem is:
I'm spliting a string and I will get 4 new strings back. Now I could do a Dim[4] and everything would be fine, but the thing is I only need the last two values.
Normally I would make sure that only the last two values of the array are returning from the function and then just put them into my two variables, all in one line. But here in AutoIt I can't figure out a simple way.
Big thanks for all help you can give me about arrays, apparently they are the new villain in my life
That's easy with StringSplit. It even creates the array with the correct dimension for you:
#include <array.au3>
$sString = "alpha,beta,gamma,delta"
$aString = StringSplit($sString, ",")
_ArrayDisplay($aString, "StringSplit")
ConsoleWrite("From StringSplit, third: " & $aString[3] & #CRLF)
ConsoleWrite("From StringSplit, fourth: " & $aString[4] & #CRLF)
; extract the last two elements:
$aString = _ArrayExtract($aString, UBound($aString) - 2)
_ArrayDisplay($aString, "Extracted")
ConsoleWrite("From Extracted, first: " & $aString[0] & #CRLF)
ConsoleWrite("From Extracted, second: " & $aString[1] & #CRLF)

Server.Mappath returning address without \

Server.MapPath("/Uploads/CrystalReport1.rpt")
and
Server.MapPath("~/Uploads/CrystalReport1.rpt")
returning address without '\'
D:WEBDATAmydomain.comUploadsCrystalReport1.rpt
but I expected
D:\WEBDATA\mydomain.com\Uploads\CrystalReport1.rpt
Your issue, noted in the comments, is that javascript interprets "\" as a marker for special characters. To output a backslash, you need to use two backslashes, as in "\". For some reason, the output is different. Instead of writing them out from the client, do a Response.Write from the code-behind, and examine the differences there, or even more simply, use VS intellisense to check.

Ruby -- Escape Single quote in variable name

I have this: my_variable = "You\'re It"
I want to find it on the page in an a tag so if I do:
page.parser.xpath("//a[contains(text(),'#{my_variable}')]")
page.parser.css('a:contains("#{temp_account_name}")')
page.parser.css("a:contains('#{temp_account_name}')")
I get an error for all the above.
But if I do:
page.parser.css('a:contains("You\'re It")')
it works. The problem is I can't use this above and place a variable in there.
How do I escape a ' character when using a variable and parsing it from the page?
On the page the text I am searching for is You're It. So I added the escape character to my variable to match and find what is on the page.
Try unescaping all the characters:
my_variable.gsub /[^\\](\\)[^\\]/, ''
...I think this is asp.net? If so, use .replace("'", "''") . Interesting solutions also exist with Server.HTMLEncode, but that's more for URLS.

regex to parse csv

I'm looking for a regex that will parse a line at a time from a csv file. basically, what string.readline() does, but it will allow line breaks if they are within double quotes.
or is there an easier way to do this?
Using regex to parse CSV is fine for simple applications in well-controlled CSV data, but there are often so many gotchas, such as escaping for embedded quotes and commas in quoted strings, etc. This often makes regex tricky and risky for this task.
I recommend a well-tested CSV module for your purpose.
--Edit:-- See this excellent article, Stop Rolling Your Own CSV Parser!
The FileHelpers library is pretty good for this purpose.
http://www.filehelpers.net/
Rather than relying on error prone regular expressions, over simpified "split" logic or 3rd party components, use the .NET framework's built in functionality:
Using Reader As New Microsoft.VisualBasic.FileIO.TextFieldParser("C:\MyFile.csv")
Reader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
Dim MyDelimeters(0 To 0) As String
Reader.HasFieldsEnclosedInQuotes = False
Reader.SetDelimiters(","c)
Dim currentRow As String()
While Not Reader.EndOfData
Try
currentRow = Reader.ReadFields()
Dim currentField As String
For Each currentField In currentRow
MsgBox(currentField)
Next
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
MsgBox("Line " & ex.Message &
"is not valid and will be skipped.")
End Try
End While
End Using

Resources