Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Waiting object?

  1. #1
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Waiting object?

    I need to convert a value from a recordset "66-BB-33" in "66BB33" to put it in a file.
    I already try to create functions using split() or replace(), but I always receive an error
    message that "waiting object" for the value passed to function. Any help please. Thanks.

    The code:
    Code:
    <% 	
    	function formataData(d) {
    		var strHoje = new Date(d);
    		var strDia = strHoje.getDate(); 
    			if (strDia < 10){ strDia = "0" + strDia }
    		var strMes = strHoje.getMonth(); 
    			strMes = strMes + 1;
    				if (strMes < 10) { strMes = "0" + strMes }
    		var strAno = strHoje.getYear();
    		var DataHoje = strDia + "-" + strMes + "-" + strAno; 
    	return DataHoje;
    	}
    
    	function separaM(matricula) {
    		var vMat = Replace(matricula,"-","");
    	return vMat;
    	}
    
    	var rs3 = Server.CreateObject("ADODB.Recordset");
     	strSQL3 = "Select * from Frota_consumo where UO= '" + vXu + "' order by x_matricula ASC, data_consumo DESC";
    	rs3.Open (strSQL3, conn); 
    	while (!rs3.EOF) { 
    	
    	vFile.WriteLine (separaM(rs3("x_matricula")) + ";" + formataData(rs3("data_consumo")) + ";" + rs3("contagem_anterior") + ";" + rs3("contagem_actual") + ";" + rs3("contagem_consumo") + ";" + rs3("litros_consumo") + ";" + rs3("custo_consumo"));
    
    %>
    The strange that I use a similar function to format a date value (formataData()) and this works fine.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,825
    Thanks
    78
    Thanked 4,413 Times in 4,378 Posts
    Replace doesn't exist in jScript. It is a VBScript function.

    For jScript you would do:
    Code:
    	function separaM(matricula) {
    		return matricula.replace(/\-/g, "" );
    	}
    Learn the methods of the language you are using! Not just functions you get from any old place.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks "Old Pedant" but with this I receive the error message: "object does not support property or method". :-(

  • #4
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Finally I find a soluction:

    Code:
    	function separaM(matricula) {
    		var vM = new String(matricula);
    		vM = vM.replace(/\-/g, "" );
    		return vM;
    	}
    I let it here to help another people. Thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •