{"id":7,"date":"2004-09-02T20:58:59","date_gmt":"2004-09-03T02:58:59","guid":{"rendered":"http:\/\/blog.hotpepper.ca\/archives\/2004\/09\/creating-vcs-files-in-coldfusion\/"},"modified":"2004-09-02T20:58:59","modified_gmt":"2004-09-03T02:58:59","slug":"creating-vcs-files-in-coldfusion","status":"publish","type":"post","link":"https:\/\/siever.ca\/kim\/2004\/09\/02\/creating-vcs-files-in-coldfusion\/","title":{"rendered":"Creating VCS Files in ColdFusion"},"content":{"rendered":"<p>One thing I have been trying for months to do on the Faculty of Management website is to create VCS files on the fly. VCS files are what Outlook and other calendaring software use to pass calendar items between each other. When I added an event to our database with ColdFusion, I wanted it to create a VCS file that the user could then download to his\/her calendar.<\/p>\n<p>Earlier this week, I came across <a href=\"http:\/\/www.cflib.org\/udf.cfm?ID=385\">Chris Wigginton\u00e2\u20ac\u2122s vCal UDF<\/a>. This ColdFusion UDF outputs the necessary information to a string. All that is needed is to write the string to a file. I used the following code to accomplish this:<\/p>\n<p><code>&lt;cffile action=\"write\" file=\"\/root\/folder\/folder\/file.vcs\" nameconflict=\"overwrite\" output=\"#vCalOutput#\" mode=\"777\" \/&gt;<\/code><\/p>\n<p>The <code>cffile<\/code> tag is used for creating, modifying and deleting files with ColdFusion.<\/p>\n<p>The <code>action<\/code> attribute is pretty self-explanatory.<\/p>\n<p>The <code>file<\/code> attribute contains a path to where the file is\/will be stored. This is not a URL. It is a direct server path. It should also be noted that some servers will require a drive letter (such as C:).<\/p>\n<p>The <code>nameconflict<\/code> attribute is used to tell ColdFusion what to do if it encounters a file named the same as that referenced in the <code>file<\/code> attribute. I used overwrite simply because I was using the <code>cffile<\/code> tag in an edit page. In this regard I was making changes to the event in the database, so I wanted those changes reflected in the VCS file.<\/p>\n<p>The <code>output<\/code> attribute is what is sent to the file referenced in the <code>file<\/code> attribute.<\/p>\n<p>The <code>mode<\/code> attribute is the permissions given to the file. Our server does some pretty funky things sometimes, so I gave read, write and execute to the owner, group and world. Anything else would probably result in a ColdFusion server error.<\/p>\n<p>One other thing to keep in mind with VCS files is that times are based on GMT. In order for me to create times for the Mountain Time Zone, I had to add 6 hours to the start and end times. For this, I used the following code:<\/p>\n<p><code>stEvent.endTime = \"#DateAdd('H', 6, CreateODBCTime(FORM.TimeEnd))#\";<\/code><\/p>\n<p>The first parameter of the <code>DateAdd<\/code> function is which element of the date\/time value you want to change. In this case, &#8216;H&#8217; corresponds to the hour. The second parameter is the number of hours to use. If you live east of the GMT, you would simply use a negative value. The third parameter is another function that converts the time-only value I use in my database to a date and time value needed for the VCS file. If you use a date-time value in your database already, you don&#8217;t need to use the <code>CreateODBCTime()<\/code> function.<\/p>\n<p>There you are. A complete solution to making VCS files in ColdFusion.<\/p>\n<p><em>Update: For some reason, VCS files do not seem to currently work in Firefox.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One thing I have been trying for months to do on the Faculty of Management website is to create VCS files on the fly. VCS files are what Outlook and other calendaring software use to pass calendar items between each other. When I added an event to our database with ColdFusion, I wanted it to create a VCS file that the user could then download to his\/her calendar.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"class_list":["post-7","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4NkW7-7","jetpack-related-posts":[{"id":130,"url":"https:\/\/siever.ca\/kim\/2005\/11\/01\/rss-and-coldfusion\/","url_meta":{"origin":7,"position":0},"title":"RSS and ColdFusion","author":"Kim Siever","date":"1 November 2005","format":false,"excerpt":"RSS is rapidly becoming a popular format for providing content. It allows users to subscribe to bits of information, so they can be notified when new information has been posted. I've been tossing around the idea of implementing RSS at work lately, and wanted to do it with ColdFusion. I\u2026","rel":"","context":"With 6 comments","block_context":{"text":"With 6 comments","link":"https:\/\/siever.ca\/kim\/2005\/11\/01\/rss-and-coldfusion\/#comments"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":21,"url":"https:\/\/siever.ca\/kim\/2004\/09\/28\/database-integration-with-flash\/","url_meta":{"origin":7,"position":1},"title":"Database Integration with Flash","author":"Kim Siever","date":"28 September 2004","format":false,"excerpt":"Dennis\u00e2\u20ac\u2122 solution was exactly what I needed. Well, actually, not quite what I needed. His solution worked for getting the data from the database and importing it to Flash. That was the biggest hurdle. What it did not do was allow for importing separate records. So I modified it.","rel":"","context":"With 2 comments","block_context":{"text":"With 2 comments","link":"https:\/\/siever.ca\/kim\/2004\/09\/28\/database-integration-with-flash\/#comments"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":159,"url":"https:\/\/siever.ca\/kim\/2006\/02\/21\/old-folders\/","url_meta":{"origin":7,"position":2},"title":"Old folders","author":"Kim Siever","date":"21 February 2006","format":false,"excerpt":"Something I have been thinking about lately is the idea of naming folders that make sense in the future. For example, it does not make sense to name a folder \"Word documents\"; a year from now you might wonder what kind of Word documents are in that folder. A common\u2026","rel":"","context":"In &quot;Accessibility&quot;","block_context":{"text":"Accessibility","link":"https:\/\/siever.ca\/kim\/category\/accessibility\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":262,"url":"https:\/\/siever.ca\/kim\/2008\/03\/28\/how-to-share-an-itunes-library-on-separate-hard-drive\/","url_meta":{"origin":7,"position":3},"title":"How to share an iTunes library on separate hard drive","author":"Kim Siever","date":"28 March 2008","format":false,"excerpt":"Ever since my wife received her iPod Shuffle this week, I have been trying to find a way for each of us to access the same music files in iTunes. We store all our music files on a separate hard drive, and until this week, I was the only iTunes\u2026","rel":"","context":"In &quot;General&quot;","block_context":{"text":"General","link":"https:\/\/siever.ca\/kim\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3625,"url":"https:\/\/siever.ca\/kim\/2019\/04\/27\/why-you-must-be-organized-with-adhd\/","url_meta":{"origin":7,"position":4},"title":"Why you must be organized with ADHD","author":"Kim Siever","date":"27 April 2019","format":false,"excerpt":"Being organized and having ADHD sometimes feels like oil and water.","rel":"","context":"In &quot;ADHD&quot;","block_context":{"text":"ADHD","link":"https:\/\/siever.ca\/kim\/category\/adhd\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/siever.ca\/kim\/wp-content\/uploads\/sites\/5\/2019\/04\/business-3190209.jpg?fit=1200%2C818&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/siever.ca\/kim\/wp-content\/uploads\/sites\/5\/2019\/04\/business-3190209.jpg?fit=1200%2C818&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/siever.ca\/kim\/wp-content\/uploads\/sites\/5\/2019\/04\/business-3190209.jpg?fit=1200%2C818&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/siever.ca\/kim\/wp-content\/uploads\/sites\/5\/2019\/04\/business-3190209.jpg?fit=1200%2C818&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/siever.ca\/kim\/wp-content\/uploads\/sites\/5\/2019\/04\/business-3190209.jpg?fit=1200%2C818&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":269,"url":"https:\/\/siever.ca\/kim\/2008\/06\/26\/printing-high-resolution-photos\/","url_meta":{"origin":7,"position":5},"title":"Printing high resolution photos","author":"Kim Siever","date":"26 June 2008","format":false,"excerpt":"A client came to me recently asking me to stitch some photos together. The photos ended up as two different files. One was a panoramic view of a city skyline at 28538x2039 pixels. The other was a view of some mountains at 5436x2410 pixels. I burned them to CD for\u2026","rel":"","context":"In &quot;Photography&quot;","block_context":{"text":"Photography","link":"https:\/\/siever.ca\/kim\/category\/photography\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/siever.ca\/kim\/wp-json\/wp\/v2\/posts\/7","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/siever.ca\/kim\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/siever.ca\/kim\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/siever.ca\/kim\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/siever.ca\/kim\/wp-json\/wp\/v2\/comments?post=7"}],"version-history":[{"count":0,"href":"https:\/\/siever.ca\/kim\/wp-json\/wp\/v2\/posts\/7\/revisions"}],"wp:attachment":[{"href":"https:\/\/siever.ca\/kim\/wp-json\/wp\/v2\/media?parent=7"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/siever.ca\/kim\/wp-json\/wp\/v2\/categories?post=7"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/siever.ca\/kim\/wp-json\/wp\/v2\/tags?post=7"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}