Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting a String to a Number

Status
Not open for further replies.

mtorbin

Technical User
Nov 5, 2002
369
US
Hey gang,

I am working on the following code snippet:

Code:
<cfset journalPrefix = Left(#URL.PubID#,2)>
<cfset journalVolume = Mid(#URL.PubID#,3,2)>
<cfset journalIssue = Mid(#URL.PubID#,6,1)>

<cfif (journalPrefix IS "HR")>
    <cfif (journalVolume = 8) AND (journalIssue >= 6)>
        <frameset rows="120,*" cols="*" frameborder="NO" border="0" framespacing="0">
	    <frame src="../../article_header.cfm?PubID=<CFOUTPUT>#URL.PubID#</CFOUTPUT>" name="header" marginwidth="10" marginheight="15" frameborder="NO" scrolling="NO" noresize>
	    <frame src="../../litAlert.cfm?KeyWords=<CFOUTPUT>#URLEncodedFormat(URL.KeyWords)#</CFOUTPUT>&PubID=<CFOUTPUT>#URL.PubID####URL.Start#</CFOUTPUT>" name="body" frameborder="NO" noresize marginwidth="10" marginheight="10">
	    </frameset>
    <cfelseif (journalVolume >= 9)>
        <frameset rows="120,*" cols="*" frameborder="NO" border="0" framespacing="0">
		<frame src="../../article_header.cfm?PubID=<CFOUTPUT>#URL.PubID#</CFOUTPUT>" name="header" marginwidth="10" marginheight="15" frameborder="NO" scrolling="NO" noresize>
		<frame src="../../litAlert.cfm?KeyWords=<CFOUTPUT>#URLEncodedFormat(URL.KeyWords)#</CFOUTPUT>&PubID=<CFOUTPUT>#URL.PubID####URL.Start#</CFOUTPUT>" name="body" frameborder="NO" noresize marginwidth="10" marginheight="10">
	    </frameset>
    </cfif>  
</cfif>

The variable that is being passed is "HR08-6-LIT". Do I need to convert journalIssue and journalVolume to a number before using it like I am? If so, what is the function?

Thanks,

- MT
 
your problem is one that trips up every coldfusion developer at some time or another

this is wrong --

<cfif (journalVolume = 8) AND (journalIssue >= 6)>

this is correct --

<cfif (journalVolume EQ 8) AND (journalIssue GE 6)>

:)

r937.com | rudy.ca
 
r937 is right. also, you can try the code below. you may want to create a generic solution since i am not sure whether all of your variables look like HR08-6-LIT.

<cfset myVal = 'HR08-6-LIT'>
<cfset myString = ReReplace(myVal, "([A-Za-z]+)", "", "ALL")>
<cfset myNum1 = Left(myString, Find("-",myString,0)-1)>
<cfset myNum2 = Mid(myString, Find("-",myString,0)+1, 1)>
<cfoutput>issue #LSParseNumber(myNum1)# :: volume #LSParseNumber(myNum2)#</cfoutput>

hope it helps...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top