Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

len() function

New Here ,
Jul 21, 2011 Jul 21, 2011

Hi all,

Am new to CFM and my client asked me to make a small change in his website. So, i identified the page and did a small change. But the change is not working.

my code is below,

<cfset new="#dato#">

        <cfset new_id="">

        <cfset new_id1="">

        <cfif len(new) lt 6>

        <cfset new_id = '00000'&new>

        <cfset new_id1 = right(new_id,6)>

        <cfelse>

        <cfset new_id1 = new>

        </cfif>

and,

<cfset mani_querybusca3 = "and c.IdCliente like '%#new_id1 #%' ">

But whats the value am generating in the cfif lines is not coming in that query line.

the value of "dato" variable is not storing to the "new" variable.

Can anyone help me to solve this issue?

Advance thanks

TOPICS
Getting started
703
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 01, 2011 Aug 01, 2011

The actual code of yours works, no problem there... even though you could do it 95% less code.

You can replace

        <cfset new="#dato#">

        <cfset new_id="">

        <cfset new_id1="">

        <cfif len(new) lt 6>

        <cfset new_id = '00000'&new>

        <cfset new_id1 = right(new_id,6)>

        <cfelse>

        <cfset new_id1 = new>

        </cfif>

With

     <cfset new_id1 = numberFormat(dato,"000000")>

There is likely a logic error somewhere else in your code.Also, using a LIKE operator when comparing an ID is usually a terrible idea.

<cfset mani_querybusca3 = "and c.IdCliente like '%#new_id1 #%' ">  <- there's an extra space already there between the 1 and # sign. Check that.

Is the dato variable coming from a query loop? if so, try outputting the dato in the first place before you do anything - checking if it really gets the value from the query - or if there's a local dato variable which overrides the query column value...

-Furnis

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 01, 2011 Aug 01, 2011
LATEST

I troubleshoot if/else logic by looking at the data.

<cfif what I expect>

yes

<cfelse>

#what I actually got#

</cfif>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources