Skip to content

Instantly share code, notes, and snippets.

@mhulse
Created May 5, 2011 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhulse/957562 to your computer and use it in GitHub Desktop.
Save mhulse/957562 to your computer and use it in GitHub Desktop.
Caché Objecscript CSP method used to extract strings out of other strings.
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
<script language="cache" method="nab" arguments='haystack:%String="", from:%String="", to:%String=""' returntype="%String" procedureblock="1">
set return = ""
if ($length(haystack) && $length(from) && $length(to)) {
//set from = "data="""
//set to = """"
set first = $find(haystack, from)
set last = $find($extract(haystack, first, $length(haystack)), to)
set return = $extract(haystack, first, (last + first - $length(to)) - 2)
}
quit return
</script>
<csp:comment>
<csp:object name="gPublication" classname="dt.cms.schema.Publication" objid="7">
<csp:object name="gStory" classname="dt.cms.schema.CMSStory" objid="26122584">
#[ new embed set embed = ##class(dt.cms.support.Rules).GetStorySWF(gStory, "", "", gPublication.name, .sc, 0) ]#
<pre>#(..EscapeHTML(embed))#</pre>
#(..nab(embed, "data=""", """"))#
<hr>
#(..nab(embed, "width=""", """"))#, #(..nab(embed, "height=""", """"))#
</csp:comment>
<csp:comment>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</csp:comment>
<dti:story:swf:exist>
<dti:file:include base="assets" file="/includes/csp/swf01.inc.csp" />
<dti:else>
Normal summary template stuff here...
</dti:story:swf:exist>
<csp:comment>
<dti:story:link><dti:story:swf /></dti:story:link>
</csp:comment>
<script language="cache" runat="server">
new embed, swf, width, height, link
set embed = ##class(dt.cms.support.Rules).GetStorySWF(gStory, "", "", gPublication.name, .sc, 0)
set swf = ##class(csp.web.assets.methods.string).nab(embed, "data=""", """")
set width = ##class(csp.web.assets.methods.string).nab(embed, "width=""", """")
set height = ##class(csp.web.assets.methods.string).nab(embed, "height=""", """")
set link = gStory.getLink(gStory.homeSectionID, gStory.defaultFullLayout)
</script>
<div class="loading" style="height:#(height)#px;"><div id="hd"></div></div>
<script type="text/javascript">
<!--
var flashvars = {
swf: '#($piece(swf, "?"))#' + '?' + encodeURIComponent('#($piece(swf, "?", 2))#'),
link: 'http://www.registerguard.com#(link)#',
loader: '#FFFFFF',
window: '_self'
};
var params = {
scale: 'noscale',
menu: 'false',
bgcolor: '#000000',
allowscriptaccess: 'always'
};
var attributes = {}
swfobject.embedSWF('http://assets.registerguard.com/v3.5/swf/loader.swf', 'hd', '#(width)#px', '#(height)#px', '9.0.115.0', false, flashvars, params, attributes);
//-->
</script>
#[ kill embed, swf, width, height, link ]#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment