Foros del Web » Programando para Internet » ASP Clásico »

contador en nº romanos

Estas en el tema de contador en nº romanos en el foro de ASP Clásico en Foros del Web. Hola a todos! necesito hacer un contador de visitas en la página principal, pero que las muestre en numeros romanos, ¿Alguien tiene una función o ...
  #1 (permalink)  
Antiguo 11/06/2008, 01:11
 
Fecha de Ingreso: abril-2008
Mensajes: 51
Antigüedad: 17 años, 1 mes
Puntos: 1
contador en nº romanos

Hola a todos!

necesito hacer un contador de visitas en la página principal, pero que las muestre en numeros romanos, ¿Alguien tiene una función o sabe como hacerlo?


gracias de antemano!
__________________
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
Publicado por: portillo18
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  #2 (permalink)  
Antiguo 11/06/2008, 07:35
Avatar de Shiryu_Libra
Colaborador
 
Fecha de Ingreso: febrero-2007
Ubicación: Cantando "Screenager" en "Kirafa Kaput"
Mensajes: 3.614
Antigüedad: 18 años, 2 meses
Puntos: 88
Respuesta: contador en nº romanos

del 1 al 9
I,II,III,IV,V,VI,VII,VIII,IX

de 10 en 10
X,XX,XXX,XL,LX,LXX,LXXX,XC

de cien en cien
C,CC,CCC,CD,D,DC,DCC,DCCC,CM

los resultados intermedios es una combinacion de todas, para que mires una pagina con ejemplos de numeros, ENTRA EN ESTA PAGINA, al parece el rango maximo en esa pagina es MMMDCCCXCIX = 3899

Utilizan este Javascript <--- con derechos de autor ---
Cita:
<script language="javascript1.1"><!--

// copyright 2002 24 Hour Translations. You may ask for permission to use this script (or a modified version)
// by contactin the webmaster at &#119&#101&#98&#109&#97&#115&#116&#101&#114&#64&#50&#52&#104&#111&#117&#114&#116&#114&#97&#110&#115&#108&#97&#116&#105&#111&#110&#115&#46&#99&#111&#46&#117&#107 with details of the site it is to be placed on.
// generally, this will require that you ensure that the following html link is visible and placed directly below the conversion box:
// <a href="http://www.24HourTranslations.co.uk/">Get an English to Latin Translation by a professional English to Latin Translator</a>

function fix(thenumber,noplaces){
var oldnumber=thenumber;
thenumber=thenumber+"00000 ";
var decpos=thenumber.indexOf(".");
if (decpos==-1) return oldnumber;
decpos=decpos+noplaces+1;
if (noplaces==0) decpos=decpos-1;
var endstring=thenumber.substring(0,decpos);
return endstring;
}

function ConvertNumber(){ // convert into Roman numerals
var array_thousands=new Array("","M","MM","MMM");
var array_hundreds=new Array("","C","CC","CCC","CD","D","DC","DCC","DCCC" ,"CM");
var array_tens=new Array("","X","XX","XXX","XL","L","LX","LXX","LXXX" ,"XC");
var array_ones=new Array("","I","II","III","IV","V","VI","VII","VIII" ,"IX");

var ones,tens,hundreds,thousands,number;
number=document.converter.number.value;
if (!(number<3900) || !(number>0)) {
document.converter.numeral.value="Out of Range";
return false;
}

ones=number%10;
tens=number%100-ones;
hundreds=number%1000-(tens+ones);
thousands=number-(hundreds+tens+ones);
document.converter.numeral.value=array_thousands[thousands/1000]+array_hundreds[hundreds/100]+array_tens[tens/10]+array_ones[ones];
}

function ConvertNumeral(){ // convert into number
var array_thousands=new Array("","M","MM","MMM");
var array_hundreds=new Array("","C","CC","CCC","CD","D","DC","DCC","DCCC" ,"CM");
var array_tens=new Array("","X","XX","XXX","XL","L","LX","LXX","LXXX" ,"XC");
var array_ones=new Array("","I","II","III","IV","V","VI","VII","VIII" ,"IX");

var ones=0;
var tens=0;
var hundreds=0;
var thousands=0;
var numeral=document.converter.numeral.value+"";
numeral=numeral.toUpperCase();

var current=0;
var width=0;
var number=0;

for (number=1; number<4; number++){ // check thousands
if (numeral.indexOf(array_thousands[number],current)==0){
thousands=number;
width=array_thousands[number].length;
}
}
current=current+width;
width=0;
for (number=1; number<10; number++){ // check hundreds
if (numeral.indexOf(array_hundreds[number],current)==current){
hundreds=number;
width=array_hundreds[number].length;
}
}
current=current+width;
width=0;
for (number=1; number<10; number++){ // check tens
if (numeral.indexOf(array_tens[number],current)==current){
tens=number;
width=array_tens[number].length;
}
}
current=current+width;
width=0;
for (number=1; number<10; number++){ // check ones
if (numeral.indexOf(array_ones[number],current)==current){
ones=number;
width=array_ones[number].length;
}
}
current=current+width;
document.converter.number.value=thousands*1000+hun dreds*100+tens*10+ones;
if (current!=numeral.length) document.converter.number.value="Out of Range";
return;
}

--></script>
pero mirando detenidamente es algo sencillo, convertirlo a funcion de ASP
un poco de paciencia y una dotacion de Coca(liquida ehh ), para que salga


p.d. esta otra pagina te puede dar numero mayores que la anterior
__________________
"Eres parte del problema, parte de la solucion o parte del paisaje"
Un Saludo desde Desierto de Altar, Sonora, MX.
Shiryu_libra

Última edición por Shiryu_Libra; 11/06/2008 a las 07:42
  #3 (permalink)  
Antiguo 11/06/2008, 08:28
 
Fecha de Ingreso: abril-2008
Mensajes: 51
Antigüedad: 17 años, 1 mes
Puntos: 1
Respuesta: contador en nº romanos

Muxas gracias Shiryu_Libra!

Ya consegui sacar lo que queria :)

bueno por si a alguien le interesa digo el procedimiento:

En el head pongo el siguiente script:

Cita:
<script>

function romanise(){

var persian=numeral.value;
var roman="";
var ronumdashes="";
var buffer=10-persian.length;

while (buffer>0) {persian="0"+persian;buffer--}

var units=new Array("","I","II","III","IV","V","VI","VII","VIII" ,"IX");
var tens=new Array("","X","XX","XXX","XL","L","LX","LXX","LXXX" ,"XC");
var hundreds=new Array("","C","CC","CCC","CD","D","DC","DCC","DCCC" ,"CM");
var thousands=new Array("","M","MM","MMM","MV","V","VM","VMM","VMMM" ,"MX");
var billionsdashes=new Array("","=","==","===","==","=","==","===","====" ,"==");

romandashes=billionsdashes[persian.substring(0,1)];

var hundredmillionsdashes=new Array("","=","==","===","==","=","==","===","====" ,"==");

romandashes+=hundredmillionsdashes[persian.substring(1,2)];

var tenmillionsdashes=new Array("","=","==","===","==","=","==","===","====" ,"==");

romandashes+=tenmillionsdashes[persian.substring(2,3)];

var millionsdashes=new Array("","_","__","___","_=","=","=_","=__","=___" ,"_=");

romandashes+=millionsdashes[persian.substring(3,4)];

var hundredthousandsdashes=new Array("","_","__","___","__","_","__","___","____" ,"__");

romandashes+=hundredthousandsdashes[persian.substring(4,5)];

var tenthousandsdashes=new Array("","_","__","___","__","_","__","___","____" ,"__");

romandashes+=tenthousandsdashes[persian.substring(5,6)];

var thousandsdashes=new Array("","","",""," _","_","_","_","_"," _");

romandashes+=thousandsdashes[persian.substring(6,7)];

roman=thousands[persian.substring(0,1)];

roman+=hundreds[persian.substring(1,2)];

roman+=tens[persian.substring(2,3)];

roman+=thousands[persian.substring(3,4)];

roman+=hundreds[persian.substring(4,5)];

roman+=tens[persian.substring(5,6)];

roman+=thousands[persian.substring(6,7)];

roman+=hundreds[persian.substring(7,8)];

roman+=tens[persian.substring(8,9)];

roman+=units[persian.substring(9,10)];
//este br iria romandashes+"<br>"+roman;
result.innerHTML=romandashes+roman;

}
</script>

En el onload del body : onload="romanise();"


Dentro del body creo una carpeta para contar visitas y el nº de visita lo pasar en la funcion romanise() a numeros romanos:

Cita:
<%
on error resume next

' Create a server object
set fso = createobject("scripting.filesystemobject")

' Target the text file to be opened
set act = fso.opentextfile(server.mappath("Contador.txt"))

' Read the value of the text document
' If the text document does not exist then the on error resume next
' will drop down to the next line
counter = clng(act.readline)

' Add one to the counter
counter = counter + 1

' Close the object
act.close

' Create a new text file on the server
Set act = fso.CreateTextFile(server.mappath("Contador.txt"), true)

' Write the current counter value to the text document
act.WriteLine(counter)

' Close the object
act.Close

' Write the counter to the browser as text
'Response.Write "" & counter
%>
<input type="hidden" value=<%=counter%> name=numeral size="10" onKeypress="if (event.keyCode<48 || event.keyCode>57) event.returnValue=false;" maxlength="10">

Por ultimo muestro las visitas en nº romanos:

Cita:

<font color="#CC0033" face="Geneva, Arial, Helvetica, sans-serif, Rockwell"><tt id=result style=font-size:10pt></tt></font>

Espero que a alguien le sirva de ayuda!


A mi me funcionó a la perfección.


Saludos
__________________
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
Publicado por: portillo18
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  #4 (permalink)  
Antiguo 13/06/2008, 02:16
 
Fecha de Ingreso: abril-2008
Mensajes: 51
Antigüedad: 17 años, 1 mes
Puntos: 1
Respuesta: Problema con contador

Buenas de nuevo!me ha vuelto a surgir un problema:

Como mencione antes todo me sale correcto o casi.

Con el código que puse antes al hacer un refresh me aumentaba el contador, lo que me piden ahora es que mientras este el explorador abierto no me aumente el contador por mucho que reinicie, pero si cierro el explorador y nuevamente lo abro otra vez y entro en la página me vuelva a aumentar las visitas.


Espero que me haya expresado bien.



Es urgente porfavor!


Gracias
__________________
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
Publicado por: portillo18
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  #5 (permalink)  
Antiguo 13/06/2008, 08:50
Avatar de Shiryu_Libra
Colaborador
 
Fecha de Ingreso: febrero-2007
Ubicación: Cantando "Screenager" en "Kirafa Kaput"
Mensajes: 3.614
Antigüedad: 18 años, 2 meses
Puntos: 88
Respuesta: contador en nº romanos

este codigo que usas es para hacerlo tipo contador de visitas???

si es asi, entonces tendras que crear un valor "contador" pero en el objeto Application del global.asa

afectaria en este sentido
Cita:
<object runat="Server" scope="Application"
id="rstActiveUsers" progid="ADODB.Recordset">
</object>

<script language="VBScript" runat="Server">
Sub Application_OnStart()
Application("NumVisitas") = 0
End Sub

Sub Session_OnStart()
Session("Start") = Now()

Application.lock()
Application("NumVisitas") = Application("NumVisitas") + 1
Application.unlock()

End Sub
</script>
tomarias el valor de la variable application
Cita:
funcionromanos(Application("NumVisitas"))
ahora que si estas realizando este tipo de contador para el usuario.... entonces deberas de anexar el valor romano, en un campo del registro del usuario

cuando ingresa el usuario, tomas el valor anterior, le sumas uno, actualizas ese valor en la tabla, y lo despliegas en la pantalla

Cita:
temp=cdbl(rs.("visita").value)
temp=temp+1
rs("visita").value=temp

en la pantalla
response.write funcionromano(rs("visita"))
solo es indicativo lo anterior, espero captes la idea

__________________
"Eres parte del problema, parte de la solucion o parte del paisaje"
Un Saludo desde Desierto de Altar, Sonora, MX.
Shiryu_libra
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:47.