{"id":888,"date":"2011-12-27T12:35:28","date_gmt":"2011-12-27T18:35:28","guid":{"rendered":"https:\/\/www.circuitdesign.info\/blog\/?p=888"},"modified":"2011-12-27T12:35:28","modified_gmt":"2011-12-27T18:35:28","slug":"skill-file-io","status":"publish","type":"post","link":"https:\/\/www.circuitdesign.info\/blog\/2011\/12\/skill-file-io\/","title":{"rendered":"Skill File I\/O"},"content":{"rendered":"<p>I keep having to look this up, so I&#8217;m going to put it here for easy reference:<\/p>\n<h3>Open a File<\/h3>\n<p><code><br \/>\nh = outfile(\"new_file.txt\", \"w\")<br \/>\nh = infile(\"existing_file.txt\")<br \/>\nh = outfile(\"partial_file.txt\", \"a\")<br \/>\n<\/code><br \/>\nOpens new file for writing, existing file for reading, and partial file for appending, respectively.<\/p>\n<h3>Write to a file<\/h3>\n<p><code><br \/>\nwrite(\"Hello World!\\n\", h)<br \/>\nfprintf(h, \"gm = %f\", OP(\"\/M23\" \"gm\"))<br \/>\nprint(OP(\"\/M23\" \"gm\"), h)<br \/>\npprint(OP(\"\/M23\" \"gm\"), h)<br \/>\n<\/code><\/p>\n<p>Write &#8220;Hello World!&#8221; to a file (newlines are explicit); construct formatted string and write to file; print using native format to a file; pretty-print (useful for nested lists etc) to a file. File handle is h.<\/p>\n<h3>Read from a file<\/h3>\n<p><code><br \/>\nstr = lineread(h)<br \/>\n<\/code>\n<\/p>\n<p>Reads a single line as a string<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I keep having to look up file I\/O using Cadence&#8217;s SKILL language, so I&#8217;m putting it here for easy reference<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[162,163,57],"class_list":["post-888","post","type-post","status-publish","format-standard","hentry","category-analog-pro","tag-file","tag-io","tag-skill"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/poCEy-ek","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.circuitdesign.info\/blog\/wp-json\/wp\/v2\/posts\/888","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.circuitdesign.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.circuitdesign.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.circuitdesign.info\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.circuitdesign.info\/blog\/wp-json\/wp\/v2\/comments?post=888"}],"version-history":[{"count":4,"href":"https:\/\/www.circuitdesign.info\/blog\/wp-json\/wp\/v2\/posts\/888\/revisions"}],"predecessor-version":[{"id":892,"href":"https:\/\/www.circuitdesign.info\/blog\/wp-json\/wp\/v2\/posts\/888\/revisions\/892"}],"wp:attachment":[{"href":"https:\/\/www.circuitdesign.info\/blog\/wp-json\/wp\/v2\/media?parent=888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.circuitdesign.info\/blog\/wp-json\/wp\/v2\/categories?post=888"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.circuitdesign.info\/blog\/wp-json\/wp\/v2\/tags?post=888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}