ANSI C标准中有几个标准预定义宏:__FILE__ __DATE__ __TIME___ __LINE__ 等
__LINE__:在源代码中插入当前源代码行号;
__FILE__:在源文件中插入当前源文件名;
__DATE__:在源文件中插入当前的编译日期
__TIME__:在源文件中插入当前编译时间;
__STDC__:当要求程序严格遵循ANSI C标准时该标识被赋值为1;
__cplusplus:当编写C++程序时该标识符被定义。
这几个宏比较有用~~~~~~~~
在调试程序时或编译时,__LINE__比较有用,可以用来打印逻辑错误的行号~~~~~~~,例子:
switch(x)
{
case 1:
....;
break;
case 2:
......
原文链接:http://www.iwapr.cn/article/daima/30.html
ASP/Visual Basic代码
<%
dim picurl,all_picurl
'皆是全局变量:分别定义图片的链接地址;所有指定文件夹(包括指定文件夹的子文件夹下图片url地址)
picurl="" '设置图片链接地址默认值为空,为下面的checkfolders()函数执行picurl=picurl&"..."做准备.
Function checkRegExp(strPattern,str) '正则匹配算法,strPattern代表正则表达式,str代表需要查询匹配的字符串
Dim Exp
if str="" or isnull(str) then '检测你 ......
<%Dim connstrconnstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Stu.mdb")
Set bb = Server.CreateObject("ADODB.Connection")
bb.Open connstr%>
<html>
<head>
<meta http-equiv="content-Language" content="zh-cn" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Asp+Access读取数据库</title>
</head>
<body>
<%Set rs = Server.CreateObject("ADODB.Recordset")
rs.open "select * from StuInfo",bb
if rs.eof and rs.bof then
response.Write "数据库中没有数据"
response.End()
end if
response.Write rs("Name")response.Write rs("Sex")
%>
</body>
</html> ......
<%Dim connstrconnstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Stu.mdb")
Set bb = Server.CreateObject("ADODB.Connection")
bb.Open connstr%>
<html>
<head>
<meta http-equiv="content-Language" content="zh-cn" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Asp+Access读取数据库</title>
</head>
<body>
<%Set rs = Server.CreateObject("ADODB.Recordset")
rs.open "select * from StuInfo",bb
if rs.eof and rs.bof then
response.Write "数据库中没有数据"
response.End()
end if
response.Write rs("Name")response.Write rs("Sex")
%>
</body>
</html> ......
IIS默认的错误页是很不友好的,很多人看到默认的错误页时都会说:网站打不开了!白白损失了这部分流量。而如果错误页直接跳转到首页又对搜索引擎很不友好,搞不好首页还会被封掉。所以根据情况,有两个方法解决这个问题:
如果是博客等内容型的网站,可以返回一个带有404错误的搜索框让访客搜索,若是电子商务型网站,则可以返回一个带有404错误的进度条进行跳转。这两种方法即照顾了访客又顾及到了SEO。
可以在Google webmaster tools中查看自己网站错误页有多少。
修改默认错误页的方法很简单:在IIS中右键单击要管理的网站,在自定义错误中设置404为相应的错误信息页。这里有两种方式:
1、如果“消息类型”你选择的是“文件”,则只能使用.html或htm结尾的文件,否则用户访问错误页时会出现代码。用这种方式设置的错误页,虽然.html文件中没有输出404状态,但IIS执行后会自动输出404状态。
2、如果你“消息类型”选择了“URL”,则必须用asp文件(因为只有在asp文件中才能设置404状态),否则访问错误页时会返回200状态码。还要在asp文件中加上:
<%Response.Status = "404 Not Found" %> ......
<!--#include file="conn.asp"-->
<%
if request.Form("username")="" or request.form("password")="" then
response.Write("<script>alert('您好,不能为空
');location.href='index.html';</script>")
end if
%>
<%
dim rs,sql,lyq,ekaida
lyq=request.form("username")
ekaida=request.form("password")
sql="select * from admin"
set rs=server.createobject("adodb.recordset")
rs.open sql,db,1,3
rs.addnew
rs("username")=lyq
rs("password")=ekaida
rs.update
rs.close
set rs=nothing
response.Write("<script>alert('您好,数据库写入成功,正在转入首页
');location.href='index.html';</script>")
%>
---------------------------------------------------------------------------------------------------
<!--#include file="conn.asp"-->
<%
username=request.form("delnet")
if request.Form("delnet&quo ......
ASP系列函数大全-网上收集的一些ASP函数及表达式
ASP函数
大全
ASP函数与VBSCRIPT类似,以下举一些常用的函数
Array()
函数返回一个数组
表达式 Array(list)
允许数据类型: 字符,数字均可
实例: <%
Dim
myArray()
For i = 1 to 7
Redim Preserve myArray(i)
myArray(i)
= WeekdayName(i)
Next
%>
返回结果:
建立了一个包含7个元素的数组myArray
myArray("Sunday","Monday", ... ...
"Saturday"
CInt()
函数将一个表达式转化为数字类型
表达式
CInt(expression)
允许数据类型: 任何有效的字符均可
实例: <%
f
= "234"
response.write cINT(f) + 2
%>
返回
结果: 236
转化字符"234"为数字"234",如果字符串为空,则返回0值
CreateObject()
函数建立和返回一个已注册的ACTIVEX组件的实例。
表达式
CreateObject(objName)
允许数据类型: objName ......