ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old May 20th, 2004, 01:37 AM
hymns hymns is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Melaka, Malaysia
Posts: 51 hymns User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 57 sec
Reputation Power: 5
Send a message via ICQ to hymns Send a message via Yahoo to hymns
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:
for($i strlen($next_category_id); $i $sibling_length$i++) $left_pad .= '0';
$next_category_id $left_pad $next_category_id


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

Reply With Quote
  #2  
Old May 20th, 2004, 07:54 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 24th Plane (16500 - 16999 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 16,743 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 2 Days 21 h 15 m 47 sec
Reputation Power: 870
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 >
__________________
r937.com | rudy.ca

Reply With Quote
  #3  
Old May 20th, 2004, 08:30 AM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,488 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 10 m 11 sec
Reputation Power: 42
I am also confused. Is this what you are trying to do?

<cfset var1 = 0>
<cfset var2 = 0>
<cfset vars = var1 & var2>

Reply With Quote
  #4  
Old May 20th, 2004, 08:12 PM
hymns hymns is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Melaka, Malaysia
Posts: 51 hymns User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 57 sec
Reputation Power: 5
Send a message via ICQ to hymns Send a message via Yahoo to hymns
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>

Reply With Quote
  #5  
Old May 21st, 2004, 08:35 AM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,488 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 10 m 11 sec
Reputation Power: 42
Quote:
Originally Posted by hymns
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>
I'm not sure what you are trying to do, especially as you are referencing variables like sibling_length and left_pad that I have no idea where they came from, how they are set, or what they contain. Can you write out what you are trying to do, or show an example of what the output is supposed to look like?

Reply With Quote
  #6  
Old May 22nd, 2004, 12:25 AM
hymns hymns is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Melaka, Malaysia
Posts: 51 hymns User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 57 sec
Reputation Power: 5
Send a message via ICQ to hymns Send a message via Yahoo to hymns
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

Reply With Quote
  #7  
Old May 23rd, 2004, 03:42 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,488 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 10 m 11 sec
Reputation Power: 42
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

Reply With Quote
  #8  
Old May 23rd, 2004, 08:53 PM
hymns hymns is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Melaka, Malaysia
Posts: 51 hymns User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 57 sec
Reputation Power: 5
Send a message via ICQ to hymns Send a message via Yahoo to hymns
wow great! it'z work

thanks kiteless!

Reply With Quote
  #9  
Old May 23rd, 2004, 08:56 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 24th Plane (16500 - 16999 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 16,743 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 2 Days 21 h 15 m 47 sec
Reputation Power: 870
<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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > cfset / cfloop


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway