QUOTE(horsemeguy @ 29 Apr, 2009 - 04:40 PM)

I want to learn cold fusion or C++, maybee both. Please give me some exaple codes that I can study, please dont give me links or advice to other places on this or any other site. I just want to get the basics.

Pleaes help me.

If you want to learn ColdFusion I know you don't want links but just check out the LiveDocs on adobe for it. But here are some Code Snippets for you.
This is a complete page for a site.
application.cfm
CODE
<cfapplication sessionmanagement="yes" sessiontimeout="#createTimeSpan(0,1,0,0)#">
<!---Retrive Scripts Folder--->
<cfajaximport scriptsrc="http://********.net/scripts/">
<!---Error Handling --->
<Cfset errors = "off">
<!---Website Variables--->
<cfset siteURL = "http://********.com/">
<!---Datasource Variables--->
<cfset mydatasource = "dlong">
<cfset myusername = "sa">
<cfset mypassword = "*******">
<!---Email Variables--->
<cfset EmailContact = "dlong@********.com">
<cfset EmailSubject = "Website Contact Form">
<cfset ReturnTo = "/thankyou.cfm">
<cfset sitetitle = "David Long">
<!---File Storage Variables--->
<cfset localpath = "C:\ColdFusion8\webroot\urbansite\">
<cfset localFilePath = "C:\ColdFusion8\webroot\urbansite\">
<cfset urlpath = "http://dlong.********.com/Files/">
<cfif errors eq "on">
<cferror type="exception" template="404.cfm" exception="any">
<cferror type="request" template="offline.cfm" exception="any">
<cfelse>
</cfif>
index.cfm
CODE
<!--- Set the parameter CatID and ID defaults --->
<cfparam name="catid" default="1">
<cfparam name="id" default="1">
<!---Include the SQL page that will get the subnav and content--->
<cfinvoke component="/common/incl_sql" method="subnav" returnvariable="getsub">
<cfinvokeargument name="mydatasource" value="#mydatasource#">
<cfinvokeargument name="myusername" value="#myusername#">
<cfinvokeargument name="mypassword" value="#mypassword#">
<cfinvokeargument name="catid" value="#catid#">
<cfinvokeargument name="id" value="#id#">
</cfinvoke>
<cfinvoke component="/common/incl_sql" method="content" returnvariable="getContent">
<cfinvokeargument name="catid" value="#catid#">
<cfinvokeargument name="id" value="#id#">
<cfinvokeargument name="mydatasource" value="#mydatasource#">
<cfinvokeargument name="myusername" value="#myusername#">
<cfinvokeargument name="mypassword" value="#mypassword#">
</cfinvoke>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<cfoutput>
<title>#sitetitle# : #getContent.title#</title>
<meta http-equiv="description" content="#getContent.meta_description#">
<meta http-equiv="keywords" content="#getContent.meta_keywords#">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</cfoutput>
<link href="/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--- Include the Admin Application page --->
<cfinclude template="/admin/incl_application.cfm">
<!--- Begin Body --->
<table cellpadding="0" cellspacing="0" border="0" width="703">
<tr><td><cfinclude template="/common/incl_header.cfm"></td></tr>
<tr><td><cfinclude template="/common/mainbody.cfm"></td></tr>
<tr><td><cfinclude template="/common/incl_footer.cfm"></td></tr>
</table>
</body>
</html>
incl_sql.cfc
CODE
<cfcomponent>
<cffunction name="subnav" output="no" access="public" returntype="query">
<cfargument name="mydatasource" type="string">
<cfargument name="myusername" type="string">
<cfargument name="mypassword" type="string">
<cfargument name="catid" default="1">
<cfargument name="id" default="1">
<cfset var getsub = "">
<cfquery name="getsub" datasource="#arguments.mydatasource#" username="#arguments.myusername#" password="#arguments.mypassword#">
SELECT *
FROM nav
WHERE catid = <cfqueryparam value="#arguments.catid#" cfsqltype="cf_sql_integer">
AND display = 'Y'
</cfquery>
<cfreturn getsub />
</cffunction>
<cffunction name="content" output="no" access="public" returntype="query">
<cfargument name="mydatasource" type="string">
<cfargument name="myusername" type="string">
<cfargument name="mypassword" type="string">
<cfargument name="catid" default="1">
<cfargument name="id" default="1">
<cfset var getcontent = "">
<cfquery name="getcontent" datasource="#arguments.mydatasource#" username="#arguments.myusername#" password="#arguments.mypassword#">
SELECT *
FROM sitecontent
WHERE cat = <cfqueryparam value="#arguments.catid#" cfsqltype="cf_sql_integer">
AND id = <cfqueryparam value="#arguments.id#" cfsqltype="cf_sql_integer">
</cfquery>
<cfreturn getContent />
</cffunction>
</cfcomponent>
incl_header.cfm
CODE
<table width="703" height="453" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="10"><img src="/Images/Urban_01.gif" width="703" height="59" alt=""></td>
</tr>
<tr>
<td colspan="4" rowspan="2"><img src="/Images/Urban_02.gif" width="271" height="214" alt=""></td>
<td colspan="3"><a href="/index.cfm"><img src="/Images/Urban_03.gif" width="112" height="47" border="0" alt=""></a></td>
<td colspan="2"><a href="/index.cfm?id=5&catid=1"><img src="/Images/Urban_04.gif" width="93" height="47" border="0" alt=""></a></td>
<td rowspan="2"><img src="/Images/Urban_05.gif" width="227" height="214" alt=""></td>
</tr>
<tr>
<td colspan="5"><img src="/Images/Urban_06.gif" width="205" height="167" alt=""></td>
</tr>
<tr>
<td><a href="/index.cfm"><img src="/Images/Home_<cfif catid eq 1>on<cfelse>off</cfif>.gif" width="64" height="26" border="0" alt="Home"></a></td>
<td><a href="/about/index.cfm"><img src="/Images/about_<cfif catid eq 2>on<cfelse>off</cfif>.gif" width="65" height="26" border="0" alt="About Us"></a></td>
<td><a href="/photos/index.cfm"><img src="/Images/photos_<cfif catid eq 3>on<cfelse>off</cfif>.gif" width="62" height="26" border="0" alt="Photos"></a></td>
<td colspan="2"><a href="/index.cfm?id=4&catid=1"><img src="/Images/contact_<cfif catid eq 1 & id eq 4>on<cfelse>off</cfif>.gif" width="98" height="26" border="0" alt="Contact Us"></a></td>
<td colspan="5" valign="top"><img src="/Images/Urban_11.gif" width="414" height="26" alt=""></td>
</tr>
<tr>
<td colspan="10" align="right" valign="top" height="52"><img src="/Images/Urban_13.gif" width="399" height="52" alt=""></td>
</tr>
<tr>
<td colspan="8"><!---Add Flash Title Here (size can be up to 467x101--->
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="467" height="101">
<param name="movie" value="../Flash/subtitle.swf">
<param name="quality" value="high">
<param name="flashvars" value="SubText=<cfoutput>#getcontent.title#</cfoutput>">
<embed src="../Flash/subtitle.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="467" height="101"></embed>
</object>
</td>
<td colspan="2"><img src="/Images/Urban_15.gif" width="236" height="101" alt=""></td>
</tr>
<tr>
<td><img src="/Images/spacer.gif" width="64" height="1" alt=""></td>
<td><img src="/Images/spacer.gif" width="65" height="1" alt=""></td>
<td><img src="/Images/spacer.gif" width="62" height="1" alt=""></td>
<td><img src="/Images/spacer.gif" width="80" height="1" alt=""></td>
<td><img src="/Images/spacer.gif" width="18" height="1" alt=""></td>
<td><img src="/Images/spacer.gif" width="15" height="1" alt=""></td>
<td><img src="/Images/spacer.gif" width="79" height="1" alt=""></td>
<td><img src="/Images/spacer.gif" width="84" height="1" alt=""></td>
<td><img src="/Images/spacer.gif" width="9" height="1" alt=""></td>
<td><img src="/Images/spacer.gif" width="227" height="1" alt=""></td>
</tr>
</table>
incl_subnav.cfm
CODE
<table cellpadding="0" cellspacing="0" border="0" width="200">
<cfif getsub.Recordcount gt 0>
<tr><td><span class="subdash">--------------------------------------</span></td></tr>
<cfloop query="getsub"><cfoutput>
<tr>
<td class="subcell">
<cfif getSub.URLLink gt " ">
<a href="#getSub.URLLink#" class="sublink"><img src="/Images/subnav_bird.gif" border="0"> #getSub.navtitle#</a>
<cfelse>
<a href="index.cfm?id=#getSub.id#&catid=#getSub.catid#" class="sublink"><img src="/Images/subnav_bird.gif" border="0"> #getSub.navtitle#</a>
</cfif>
</td>
</tr>
<tr><td><span class="subdash">--------------------------------------</span></td></tr>
</cfoutput></cfloop>
</cfif>
</table>
mainbody.cfm
CODE
<p />
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="200" style="padding-right:10px; "><cfinclude template="/common/incl_subnav.cfm"></td>
<td style="border-left-width:1px; border-left-style:solid; border-left-color:#999999; "> </td>
<td><cfinclude template="/common/incl_content.cfm"></td>
</tr>
</table>
incl_content.cfm
CODE
<p>
<cfoutput><span class="content">#getContent.content#</span></cfoutput>
</p>
<cfif id eq 4>
<p><cfinclude template="/admin/common/incl_contact.cfm"></p>
<cfelseif id eq 5>
<p><cfinclude template="/admin/common/incl_sitemap.cfm"></p>
</cfif>
That is almost an entire website page. All I have to do is change the id and catid in the index.cfm page and I can pull almost any of my pages from the DB