|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
cfset / cfloop
i've problem to create var with two var
i try to create var1 = 0 var2 = 0 vars = var1 var2 vars = 00 bcoz php using dot (.) to combine an i try use cfloop for replace the for below. any idea? PHP Code:
CFM: <cfset left_pad = 0> <cfset i = len(next_category_id)> <cfloop condition = "i LESS THAN sibling_length"> <cfset i = i + 1> <cfset a_pad = insert(0,left_pad,1)> </cfloop>
__________________
Making it different not a profit |
|
#2
|
||||
|
||||
|
if you would explain what you are trying to do, i'm sure there will be a simpler way to do it than looping
as for the actual syntax, what you are looking for is concatenation php uses a dot, coldfusion uses the ampersand <cfset concat = foo & bar > |
|
#3
|
|||
|
|||
|
I am also confused. Is this what you are trying to do?
<cfset var1 = 0> <cfset var2 = 0> <cfset vars = var1 & var2> |
|
#4
|
|||
|
|||
|
Yeah right! Using &! It'z work!
Anybody can make this code very simple than this? I think it too long <cfset i = len(next_category_id)> <cfloop condition = "i LESS THAN sibling_length"> <cfset i = i + 1> <cfif IsDefined("left_pad")> <cfset left_pad = 0 & left_pad> <cfelse> <cfset left_pad = "0"> </cfif> </cfloop> <cfset next_category_id = left_pad & next_category_id> |
|
#5
|
|||
|
|||
|
Quote:
|
|
#6
|
|||
|
|||
|
thanks for the reply, anyway i try combine the variable to make an id.
<!--- Set by default ---> sibling_length = 3 <!--- from agrument ---> next_category_id = 000 or XXX or can be xxxnnnzzz and the result for next category id next_category_id = 00N or 00N00N |
|
#7
|
|||
|
|||
|
Well it seems to me that if you want to give the system a number, like 3, and then have it spit out an "id" like XXX, you could do something like:
<cfset lengthOfID = 3 /> <cfset ID = "" /> <cfloop index="i" from="1" to="#lengthOfID#"> <cfset ID = ID & "X" /> </cfloop> At the end, ID would be "XXX".
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#8
|
|||
|
|||
|
wow great! it'z work
thanks kiteless! |
|
#9
|
||||
|
||||
|
<cfset lengthOfID = 3 >
<cfset ID = Left('XXXXXXXXXXXXXXXXXXXXXXXXXX',LengthofID)> when did the slash to "close" a CFSET tag become popular? maybe they should call it xCFML ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > cfset / cfloop |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|