4
Nov/080
Nov/080
Função “três pontinhos”
Código simples para você ter aqueles "três pontinhos" em sua notícia, feeds etc...
Usando VBScript
<%@ Language="VBScript" %> <% Public Function Pontos(VarTexto, Max) ' Recebemos os valores If Int(Len(VarTexto)) > Max Then Response.Write(Left(VarTexto, Max)&"...") ' Usamos a função "substring" para fazer os cortes Else Response.Write(VarTexto) End If End Function Texto = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the whenwhen, when an unknown printer took a galley of type and scrambled it to make a type specimen book." Call Pontos(Texto, 150) ' Chamando a função e mostrando o resultado %>
Agora usando JScript com ASP
<%@ Language="JScript" %>
<%
function pontos(varTexto, Max) { // Recebemos os valores
if (varTexto.length > Max) {
Response.Write(varTexto.substring(0, Max)+"..."); // Usamos a função "substring" para fazer os cortes
}
else {
Response.Write(varTexto);
}
}
texto = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the whenwhen, when an unknown printer took a galley of type and scrambled it to make a type specimen book.";
pontos(texto, 150); // Chamando a função e mostrando o resultado
%>


