<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Passing text to the settings property from Main and Form classes in EG Custom Task in VB.Net in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Passing-text-to-the-settings-property-from-Main-and-Form-classes/m-p/109237#M9339</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once again your answer has helped me resolve my problem.&amp;nbsp; Although you suggested that I didn't need to convert to XML, I ended up using the ToXml and FromXml routine supplied in the VB.Net template (for simplicity), and borrowing some code from the BasicStatsVB_withUI project to pass the _settings data to and from the form.&amp;nbsp; I also moved the ToSasProgram function from Settings to Main, so that it was with the related code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I think I now understand why my old "Proc Report" custom task, that worked fine in EG 4.1, stopped working in EG 4.2, and I think I now understand how to fix it.&amp;nbsp; This means I have yet another EG Add-in project to complete!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know you don't like VB.Net, but thanks for tolerating it enough to help me out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks...........Phil&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS. I am building a template extractor for ODS Styles, Statgraphs and Tables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Oct 2012 22:07:57 GMT</pubDate>
    <dc:creator>prholland</dc:creator>
    <dc:date>2012-10-29T22:07:57Z</dc:date>
    <item>
      <title>Passing text to the settings property from Main and Form classes in EG Custom Task in VB.Net</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Passing-text-to-the-settings-property-from-Main-and-Form-classes/m-p/109235#M9337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to generate some code to run in EG 5.1 that is based on 3 List Box objects in VB.Net.&amp;nbsp; I'd like to pass a comma-separated list of values from the Form class, via the Settings class, to the Main class of an EG Custom Task.&amp;nbsp; I've used the following VB.Net (VS 2010) code to pass the _settings object from Main to Form, but, even though I get no errors, nothing appears back in my GetSasCode routine when I read the _settings properties back in Main.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Main:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private _settings As New Settings&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; form._settings = _settings&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; form.ShowDialog(Owner)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' save the settings from the form&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _settings = form._settings&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Overrides Function GetSasCode() As String&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' generate the SAS program and return as a String&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return _settings.ToSasProgram()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Form:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public _settings As Settings&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim sb As New StringBuilder()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim i As Integer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If lstStyle.SelectedItems.Count &amp;gt; 0 Then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For i = 0 To (lstStyle.SelectedItems.Count - 1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.AppendFormat(",{0}", lstStyle.SelectedItems(i).ToString())&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If lstStatgraph.SelectedItems.Count &amp;gt; 0 Then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For i = 0 To (lstStatgraph.SelectedItems.Count - 1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.AppendFormat(",{0}", lstStatgraph.SelectedItems(i).ToString())&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If lstTable.SelectedItems.Count &amp;gt; 0 Then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For i = 0 To (lstTable.SelectedItems.Count - 1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.AppendFormat(",{0}", lstTable.SelectedItems(i).ToString())&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _settings._runcode = sb.ToString().Substring(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Settings:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Property _runcode As String&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Settings ToSasProgram:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim sb As New StringBuilder()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim run_code1 As String&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim template_name As String&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run_code1 = _runcode&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; While Not String.IsNullOrEmpty(run_code1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; template_name = run_code1.Substring(0, run_code1.IndexOf(","))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.AppendFormat(" source {0};", template_name)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.AppendLine()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run_code1 = run_code1.Substring(run_code1.IndexOf(",") + 1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End While&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;_runcode appears to contain nothing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why is this happening?stom............Phil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Oct 2012 22:25:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Passing-text-to-the-settings-property-from-Main-and-Form-classes/m-p/109235#M9337</guid>
      <dc:creator>prholland</dc:creator>
      <dc:date>2012-10-27T22:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: Passing text to the settings property from Main and Form classes in EG Custom Task in VB.Net</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Passing-text-to-the-settings-property-from-Main-and-Form-classes/m-p/109236#M9338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Phil,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A couple of observations...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- assuming that your Form class has an OK and Cancel button, you should be checking that the DialogResult from your ShowDialog() call is DialogResult.OK before you "commit" the setting values in your task class.&amp;nbsp; (See also: &lt;A href="http://blogs.sas.com/content/sasdummy/2009/01/06/10-tips-for-creating-dialog-windows-like-the-pros/" title="http://blogs.sas.com/content/sasdummy/2009/01/06/10-tips-for-creating-dialog-windows-like-the-pros/"&gt; 10 tips for creating dialog windows like the pros - The SAS Dummy&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- you're missing a very important part of the task: the part where you save the task settings and then restore them via the XmlState property.&amp;nbsp; In the SasTask-derived class, this is done by overriding the GetXmlState (to save) and RestoreStateFromXml (to restore).&amp;nbsp; The convention is to pass the values via XML, but that is not strictly required.&amp;nbsp; So for your task, you could add this to your task class ("Main"):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Overrides Function GetXmlState() As String&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return _settings&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Overrides Sub RestoreStateFromXml(ByVal xmlState As String)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _settings = xmlState&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This step is necessary because your task class instance is &lt;STRONG&gt;not reused&lt;/STRONG&gt; from the "design phase" where you work with the UI to the "run" phase where your class generates a program to run within EG. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Think of your task class as an empty container.&amp;nbsp; During "design" (when you see the UI), you are collecting information that is needed to fulfill the task's purpose.&amp;nbsp; After you click OK and close the UI, the information is stored away in your project, and your task class (container) goes away (freeing memory).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When it comes time to &lt;STRONG&gt;run&lt;/STRONG&gt; the task (which may be just milliseconds later), a new task container is created, and the stored information from the project is "poured" into it (via the XmlState property, or the above override functions).&amp;nbsp; This -- along with the Consumer.ActiveData, perhaps -- provides you with the state information you need to create the SAS program that you want to run.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Oct 2012 13:36:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Passing-text-to-the-settings-property-from-Main-and-Form-classes/m-p/109236#M9338</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2012-10-29T13:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Passing text to the settings property from Main and Form classes in EG Custom Task in VB.Net</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Passing-text-to-the-settings-property-from-Main-and-Form-classes/m-p/109237#M9339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once again your answer has helped me resolve my problem.&amp;nbsp; Although you suggested that I didn't need to convert to XML, I ended up using the ToXml and FromXml routine supplied in the VB.Net template (for simplicity), and borrowing some code from the BasicStatsVB_withUI project to pass the _settings data to and from the form.&amp;nbsp; I also moved the ToSasProgram function from Settings to Main, so that it was with the related code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I think I now understand why my old "Proc Report" custom task, that worked fine in EG 4.1, stopped working in EG 4.2, and I think I now understand how to fix it.&amp;nbsp; This means I have yet another EG Add-in project to complete!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know you don't like VB.Net, but thanks for tolerating it enough to help me out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks...........Phil&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS. I am building a template extractor for ODS Styles, Statgraphs and Tables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Oct 2012 22:07:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Passing-text-to-the-settings-property-from-Main-and-Form-classes/m-p/109237#M9339</guid>
      <dc:creator>prholland</dc:creator>
      <dc:date>2012-10-29T22:07:57Z</dc:date>
    </item>
  </channel>
</rss>

