Look at the list functions and the string functions (help for all should be
in studio or one of the books; get one!)

For lists, you can use any character as a delimiter, so you can do
listLen("your number",".").  

If it's 1, you have a number of the form 9999; it it's 2, you have a number
of the form 9999.99999999; if you might have numbers of the form
..9999999999999, you'll have to check for "." in position 1 of the string.
AND if you have numbers in the form of 999.999.999 you'll have to deal with
that.  Bottom line, validate the form of the input before the following code
processes.


This was quick, ymmv --

<cfoutput>
<cfset myValidatedNumberString = "123.994567857"> <!--- replace with your
own --->
<cfset myListCounter = listLen(myValidatedNumberString,".")>
<cfset myVarCounter = 1>
<cfset currentPart = "">
<cfloop index="part" from="1" to="#myListCounter#">
        <cfset currentPart = listGetAt(myValidatedNumberString,part,".")>
        <cfif part EQ 1>
                <cfset ws = setVariable("var_" & myVarCounter, currentPart)>
                <cfset myVarCounter = myVarCounter + 1>                 
        <cfelseif part EQ 2>
                <cfset toCount = (len(currentPart)/2) + (len(currentPart)
MOD 2)>
                <cfloop index="startPosition" from="1" to="#toCount#"> 
                <!--- if it's odd, you'll need to get that last single digit
--->
                        <cfset ws = setVariable("var_" & myVarCounter,
mid(currentPart,(startPosition*2)-1,2))>
                        <cfset myVarCounter = myVarCounter + 1>

                </cfloop>
        </cfif>
</cfloop>


<cfloop index="counter" from="1" to="#evaluate(myVarCounter - 1)#">
        var_#counter# = #evaluate("var_" & counter)#<br>
</cfloop>
</cfoutput>
        



-----Original Message-----
From: Jordie Fike [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 30, 2000 10:23 AM
To: CF-Talk
Subject: a bbs in cf


first a thank you to those that helped me with my "dates in a sql 
statement" problem .. it has taken me close to fruition on my current pet 
project .. but now I've run into another road block

My Immediate Problem:
can anyone point me in the proper direction so that I might be able to 
learn what specific functions that are available in CF to read the contents 
of strings/variables? What I need to accomplish is to take something of the 
form

1234.010203

and be able to break it up into

is_there_a_period = 1
var_1 = 1234
var_2 = 01
var_3 = 02
var_4 = 03

when I won't know the length of what's before or after the period. i.e. 
they might be of the form

12
or
1234
or
1234.01
or
1234.0102
etc.

I know I can find the presence of the period with

<CFSET is_there_a_period = ListContains(#sort_key#, ".")>

but I don't know how to find out how many characters there are to the right 
or left of the period if it does exist, and what the value of these 
individual characters on either side of the period are.

What I'm Up To:
A while back I implemented a BBoard written in Tcl on 
OuterBanksBeachGuide.com - it was written by Phillip Greenspun of MIT. It 
has served us well through it's 4 year life span, but lately I've had 
clients asking for something similar on their sites. The problem with 
continuing to use Phillip's board is that it requires an AOLServer backed 
hosting solution and they don't come cheap. So I went looking for something 
written in CF at a comparable price (did I mention that Phillip's app is 
open source) but wasn't able to find much .. so then I get the bright idea 
to try and port Phillip's board from Tcl to CF. I checked with Phillip to 
make sure he was OK with this idea and he assured me that he is. Although 
it is my hope to get this functional on my own .. I would like to turn this 
into an open source project of it's own.

If this is something that you feel you would like to be involved in or if 
you would like a copy once I get it working please feel free to email me 
direct .. just so long as you are charging for your time installing the 
application and not selling the app itself. If anyone knows that I am 
reinventing the wheel and that something like this is already available, if 
you would kindly email me a quick note to point me in the right direction I 
would greatly appreciate it.

Jordie Fike
Tech Admin
[EMAIL PROTECTED]
http://www.outer-banks.nc.us
phone - 1.252.441.6698
fax - 1.252.480.2259
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to