<?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: ilogic Functions &amp;amp;/Or Sub Routines Passing Arguments Back To Main Code in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-functions-amp-or-sub-routines-passing-arguments-back-to/m-p/9298651#M66907</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8599860"&gt;@Tim_Mulder&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Welcome to the forum.&amp;nbsp;In addition to the previous replies, this simple example might help illustrate the use of a function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;BR /&gt;Best of luck to you in all of your Inventor pursuits,&lt;BR /&gt;Curtis&lt;BR /&gt;&lt;A href="http://inventortrenches.blogspot.com" target="_blank" rel="noopener"&gt;http://inventortrenches.blogspot.com&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub Main

'basket 1
Apples = 10
Oranges = 10

'get qty of basket1
Basket1 = QTY_Fruit( Apples, Oranges)

'basket 2
Apples = 2
Oranges = 3

'get qty of basket2
Basket2 = QTY_Fruit( Apples, Oranges) 

MsgBox(Basket1 + Basket2 &amp;amp; " total pcs")
End Sub

Function QTY_Fruit(A As Integer, O As Integer )

	'calc fruit
	&lt;FONT color="#0000FF"&gt;oQTY&lt;/FONT&gt; = A + O
	
	'send sum back to main sub
	&lt;FONT color="#0000FF"&gt;Return oQTY&lt;/FONT&gt; 
End Function&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and here is a slightly different way of doing this based on the syntax that&amp;nbsp;bradeneuropeArthur&amp;nbsp;'s example used to write and return the function.&lt;/P&gt;
&lt;PRE&gt;Sub Main

'basket 1
Apples = 10
Oranges = 10

'get qty of basket1
Basket1 = QTY_Fruit( Apples, Oranges)


'basket 2
Apples = 2
Oranges = 3

Basket2 = QTY_Fruit( Apples, Oranges) 

MsgBox(Basket1 + Basket2 &amp;amp; " total pcs")
End Sub

Function &lt;FONT color="#0000FF"&gt;QTY_Fruit&lt;/FONT&gt; (A As Integer, O As Integer ) &lt;FONT color="#0000FF"&gt;As Integer&lt;/FONT&gt;

	'calc fruit
	&lt;FONT color="#0000FF"&gt;QTY_Fruit&lt;/FONT&gt; = A + O

End Function&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Feb 2020 16:08:49 GMT</pubDate>
    <dc:creator>Curtis_Waguespack</dc:creator>
    <dc:date>2020-02-05T16:08:49Z</dc:date>
    <item>
      <title>ilogic Functions &amp;/Or Sub Routines Passing Arguments Back To Main Code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-functions-amp-or-sub-routines-passing-arguments-back-to/m-p/9297264#M66904</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm struggling to understand Functions &amp;amp;/Or Sub Routines in ilogic.&lt;BR /&gt;In effect I am trying to have a function/sub routine within my code that stores a list of integers.&lt;/P&gt;&lt;P&gt;Then I want return some of those integers (with some if else statements) to my called&amp;nbsp;function/sub routine so Ican use these values elsewhere. I have a rough idea of how functions work in VBA but that doesn't seem to translate to ilogic, unless I am missing something. Here is what I have so far&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Sub Main
Call SplitPinCalc((BoltSize), Split_Pin, Split_Pin_Hole, Split_Pin_Dist)
'These values above don't update with function values below
End Sub

Function SplitPinCalc(BoltSize As Integer, Split_Pin As Integer, Split_Pin_Hole As Integer, Split_Pin_Dist As Integer)
If BoltSize = "12" Then
	Split_Pin = 3
	Split_Pin_Hole = 4
	Split_Pin_Dist = BoltSize*2
Else If 'Blah Blah Blah
End If
Return SplitPinCalc
End Function&lt;/PRE&gt;&lt;P&gt;My code so far enters into the function and works as intended, but those values are not passed back up to the called function arguments.&lt;/P&gt;&lt;P&gt;Any help &amp;amp; instruction would be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2020 06:57:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-functions-amp-or-sub-routines-passing-arguments-back-to/m-p/9297264#M66904</guid>
      <dc:creator>Tim_Mulder</dc:creator>
      <dc:date>2020-02-05T06:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: ilogic Functions &amp;/Or Sub Routines Passing Arguments Back To Main Code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-functions-amp-or-sub-routines-passing-arguments-back-to/m-p/9297493#M66905</link>
      <description>&lt;P&gt;What would you like to be returned for the function:&lt;/P&gt;
&lt;PRE&gt;Split_Pin = 3
	Split_Pin_Hole = 4
	Split_Pin_Dist&lt;/PRE&gt;
&lt;P&gt;This function can only return one value.&lt;/P&gt;
&lt;P&gt;If you need more you need to create a Class.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2020 08:54:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-functions-amp-or-sub-routines-passing-arguments-back-to/m-p/9297493#M66905</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2020-02-05T08:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: ilogic Functions &amp;/Or Sub Routines Passing Arguments Back To Main Code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-functions-amp-or-sub-routines-passing-arguments-back-to/m-p/9297502#M66906</link>
      <description>&lt;P&gt;This is how it works in basics&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Public Sub main()
MsgBox a(2)
End Sub
Private Function a(b As Integer) As Integer

If b = 1 Then
a = 11
End If

If b = 2 Then
a = 22
End If

End Function&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Feb 2020 08:58:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-functions-amp-or-sub-routines-passing-arguments-back-to/m-p/9297502#M66906</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2020-02-05T08:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: ilogic Functions &amp;/Or Sub Routines Passing Arguments Back To Main Code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-functions-amp-or-sub-routines-passing-arguments-back-to/m-p/9298651#M66907</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/8599860"&gt;@Tim_Mulder&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Welcome to the forum.&amp;nbsp;In addition to the previous replies, this simple example might help illustrate the use of a function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;BR /&gt;Best of luck to you in all of your Inventor pursuits,&lt;BR /&gt;Curtis&lt;BR /&gt;&lt;A href="http://inventortrenches.blogspot.com" target="_blank" rel="noopener"&gt;http://inventortrenches.blogspot.com&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub Main

'basket 1
Apples = 10
Oranges = 10

'get qty of basket1
Basket1 = QTY_Fruit( Apples, Oranges)

'basket 2
Apples = 2
Oranges = 3

'get qty of basket2
Basket2 = QTY_Fruit( Apples, Oranges) 

MsgBox(Basket1 + Basket2 &amp;amp; " total pcs")
End Sub

Function QTY_Fruit(A As Integer, O As Integer )

	'calc fruit
	&lt;FONT color="#0000FF"&gt;oQTY&lt;/FONT&gt; = A + O
	
	'send sum back to main sub
	&lt;FONT color="#0000FF"&gt;Return oQTY&lt;/FONT&gt; 
End Function&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and here is a slightly different way of doing this based on the syntax that&amp;nbsp;bradeneuropeArthur&amp;nbsp;'s example used to write and return the function.&lt;/P&gt;
&lt;PRE&gt;Sub Main

'basket 1
Apples = 10
Oranges = 10

'get qty of basket1
Basket1 = QTY_Fruit( Apples, Oranges)


'basket 2
Apples = 2
Oranges = 3

Basket2 = QTY_Fruit( Apples, Oranges) 

MsgBox(Basket1 + Basket2 &amp;amp; " total pcs")
End Sub

Function &lt;FONT color="#0000FF"&gt;QTY_Fruit&lt;/FONT&gt; (A As Integer, O As Integer ) &lt;FONT color="#0000FF"&gt;As Integer&lt;/FONT&gt;

	'calc fruit
	&lt;FONT color="#0000FF"&gt;QTY_Fruit&lt;/FONT&gt; = A + O

End Function&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2020 16:08:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-functions-amp-or-sub-routines-passing-arguments-back-to/m-p/9298651#M66907</guid>
      <dc:creator>Curtis_Waguespack</dc:creator>
      <dc:date>2020-02-05T16:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: ilogic Functions &amp;/Or Sub Routines Passing Arguments Back To Main Code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-functions-amp-or-sub-routines-passing-arguments-back-to/m-p/9299905#M66908</link>
      <description>&lt;P&gt;Thanks for your reply,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find in picture what I'm intending the function or sub to achieve.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Intended Function_Sub.png" style="width: 971px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/726412iC1F9207855DCEC09/image-size/large?v=v2&amp;amp;px=999" role="button" title="Intended Function_Sub.png" alt="Intended Function_Sub.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the feeling I may be trying to do something the Function can't handle.&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 01:09:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-functions-amp-or-sub-routines-passing-arguments-back-to/m-p/9299905#M66908</guid>
      <dc:creator>Tim_Mulder</dc:creator>
      <dc:date>2020-02-06T01:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: ilogic Functions &amp;/Or Sub Routines Passing Arguments Back To Main Code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-functions-amp-or-sub-routines-passing-arguments-back-to/m-p/9300240#M66909</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try&amp;nbsp; this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;Main&lt;/SPAN&gt;

&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;Spin_Pin&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Integer&lt;/SPAN&gt; = 0
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;Spin_Pin_Hole&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Integer&lt;/SPAN&gt; = 0
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;Spin_Pin_Dist&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Integer&lt;/SPAN&gt; = 0

&lt;SPAN&gt;'Array&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;result&lt;/SPAN&gt;(2) &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Integer&lt;/SPAN&gt;

&lt;SPAN&gt;'Call the Function&lt;/SPAN&gt;
&lt;SPAN&gt;result&lt;/SPAN&gt; = &lt;SPAN&gt;SplitPinCalc&lt;/SPAN&gt;(12)

&lt;SPAN&gt;'Store the results &lt;/SPAN&gt;
&lt;SPAN&gt;Spin_Pin&lt;/SPAN&gt; = &lt;SPAN&gt;result&lt;/SPAN&gt;(0)
&lt;SPAN&gt;Spin_Pin_Hole&lt;/SPAN&gt; = &lt;SPAN&gt;result&lt;/SPAN&gt;(1)
&lt;SPAN&gt;Spin_Pin_Dist&lt;/SPAN&gt; = &lt;SPAN&gt;result&lt;/SPAN&gt;(2)

&lt;SPAN&gt;'Display the Result&lt;/SPAN&gt;
&lt;SPAN&gt;MessageBox&lt;/SPAN&gt;.&lt;SPAN&gt;Show&lt;/SPAN&gt;(&lt;SPAN&gt;"Pin is:"&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;Spin_Pin&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;" - Hole is:"&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;Spin_Pin_Hole&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;" - Distance is:"&lt;/SPAN&gt; &amp;amp; &lt;SPAN&gt;Spin_Pin_Dist&lt;/SPAN&gt; )

&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;


&lt;SPAN&gt;Function&lt;/SPAN&gt; &lt;SPAN&gt;SplitPinCalc&lt;/SPAN&gt;(&lt;SPAN&gt;Boltsize&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Integer&lt;/SPAN&gt;) &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Integer&lt;/SPAN&gt;()
	
	
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;fResult&lt;/SPAN&gt;(2) &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Integer&lt;/SPAN&gt;
	
	&lt;SPAN&gt;'Condition&lt;/SPAN&gt;
	&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;Boltsize&lt;/SPAN&gt; = 12 &lt;SPAN&gt;Then&lt;/SPAN&gt;
		&lt;SPAN&gt;fResult&lt;/SPAN&gt;(0) = 3 &lt;SPAN&gt;'Pin&lt;/SPAN&gt;
		&lt;SPAN&gt;fResult&lt;/SPAN&gt;(1) = 4 &lt;SPAN&gt;'Hole&lt;/SPAN&gt;
		&lt;SPAN&gt;fResult&lt;/SPAN&gt;(2) = &lt;SPAN&gt;Boltsize&lt;/SPAN&gt; * 2 &lt;SPAN&gt;'Dist&lt;/SPAN&gt;
	&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
	
	&lt;SPAN&gt;'Return Value (Array)&lt;/SPAN&gt;
	&lt;SPAN&gt;SplitPinCalc&lt;/SPAN&gt; = &lt;SPAN&gt;fResult&lt;/SPAN&gt;
	
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Function&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 08:07:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-functions-amp-or-sub-routines-passing-arguments-back-to/m-p/9300240#M66909</guid>
      <dc:creator>laszlo_nagy</dc:creator>
      <dc:date>2020-02-06T08:07:27Z</dc:date>
    </item>
  </channel>
</rss>

