I prefer to use Right() and Left() because they are quicker to type and easier to read.
Printable View
I prefer to use Right() and Left() because they are quicker to type and easier to read.
Yeah, Left and right produce cleaner code.
SD
Oh you weak coders. :)
Anyway... 'nother problem.
Result is "1"Code:<%
Option Explicit
dim i
i = 0
myFunc
Response.Write(i)
Private Function myFunc()
i = 1
End Function
%>
Result is "0"Code:<%
Option Explicit
dim i
i = 0
myFunc
Response.Write(i)
Private Function myFunc()
dim i
i = 1
End Function
%>
This is VBScript and ASP. What is the point behind Option Explicit if you are not going to complain when I use a variable that is very blatantly out of scope! And why are you letting affect a variable that is not in my scope. I've even use "private i" on the dim statement in the beginning of the code, and it makes no difference.
VB/VBScript is broken.
Sorry, don't know diddly squat about vbscript.
P.S. Clean code = Easily Maintained Code :)
SD
Actually now that I look at it, the first example i is a module level variable, and therefore is in scope. It can be accessed from all modules.
In the second the 'dim i' in the function takes precedence over the first 'dim i' and is therefore a different variable.
So it appears to be functioning correctly. The variables are operating within their scopes.
SD
*grumble*
Me thinks you're right. Which means 'private' and 'public' don't mean anything in VBScript.
Well, that still doesn't help me. I'm used to the idea that if you want a variable to have scope in seperate functions, you have to explicitly make it public. Here, all of them are public, and you can't make them private.
My problem is... I have a large ASP that is getting hairy. I want to re-write it, now that the project and its direction are much clearer. I want to put the new functionality that we add in seperate functions. These self contained functions can be carried to the new rewrite, and won't bother the current version.
But... they will bother the current version because it is a simple step through VBScript, with no seperate functions. ASP doesn't require a main function, it is a scripting technology.
Ahwell.. wait.. I can add these functions, becuase each one will declare its own variables, and they will have scope over the module level ones. Okay... so my problem is, Option Explicit wasn't complaining when I wanted it to, so I can't rely on it (no biggie).
I think today is a bad morning for us all.
Have a good rant, it did me wonders.Quote:
Originally posted by CiberTHuG
I think today is a bad morning for us all.
SD
Yes, and I feel I have to apologize. Sorry.
As a juvenille side note...
fART.inc is a bad file name, but it was by accident. It was supposed to be "function Average Response Time include file" for the ASP project. Good thing they are .inc and not .ing.
Yes l read your GW thread:mad: What happened, bad bottle of shirazQuote:
Originally posted by SurfDemon
Have a good rant, it did me wonders.
SD
Multiline comments!
Yeah! go brother! eah! You show them who's right.....Quote:
Originally posted by Wynd
Multiline comments!
.... err what are you talking about again? :D it seems to have slipped my tiny mind ;)
SD
Yes, definitely!Quote:
Originally posted by Wynd
Multiline comments!
I just wish all the components were embedded, and someone wouldn't need all these extra files to run it. Then it would be a true EXE!
Well, in C++ you can comment out one line:Quote:
Originally posted by SurfDemon
Yeah! go brother! eah! You show them who's right.....
.... err what are you talking about again? :D it seems to have slipped my tiny mind ;)
or you can comment out lots of lines, useful for when you need to temporarily disable a block of code:Code://comment
But in VB, all you have is the single line.Code:/*
for (int i = 0; i <= 10; i++)
{
cout<<"hello"<<endl;
}
...
many lines of code here...
*/
True, but this is a double edged sword. speaking as someone who regularly forgets to close comments and effectively removes whole piles of code in one fell swoop.....:) of course it makes it compile faster!
LOL:DQuote:
Originally posted by SurfDemon
True, but this is a double edged sword. speaking as someone who regularly forgets to close comments and effectively removes whole piles of code in one fell swoop.....:) of course it makes it compile faster!
..but wouldn't you notice it if half your code turns green on you? (Or if your code compiles ten times faster and nothing works :D)
Unfortunately all my code was green as I used to code C on a Vax mainframe and it was a green screen monitor (VT Terminal) :DQuote:
Originally posted by Tygur
LOL:D
..but wouldn't you notice it if half your code turns green on you? (Or if your code compiles ten times faster and nothing works :D)