Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I am very happy with the whole site and would like to extend my compliments to all of you who work to make it one of the most useful sites (If not THE Most Useful) ...and the easiest to navigate..."

Geography

Where in the world do Tek-Tips members come from?

VBScript with a subroutine calling itself

jmarkus (TechnicalUser)
27 Jun 12 11:16
I am trying to write a VBScript to perform some nested functions. Within my Subroutine I need to call the same subroutine (passing a different variable) until I have worked through the structure. What are the limitations (if any) I need to understand to make it work. For the record, my script currently runs correctly in terms of reporting out the values of various variables, but it doesn't perform the functions on those variables correctly. It is almost as if once it gets into the first nested call of the subroutine it nulls the functions and doesn't do anything.

I hope that makes sense and somebody can help shed some light on the subject.

Thanks,
Jeff
SkipVought (Programmer)
27 Jun 12 11:22
hi,

Post your code.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

jmarkus (TechnicalUser)
27 Jun 12 11:33
This is the basic VBScript (it runs inside CATIA):

CODE

Sub CATMAIN()
Dim oTopProduct As Product
Dim MainDocument As ProductDocument
Set MainDocument = CATIA.ActiveDocument
Set oTopProduct = MainDocument.Product

Call TurnOff(oTopProduct)

End Sub

Sub TurnOff(oTopProduct)

Dim i,j
Dim selection1 As Selection
Dim visPropertySet1 As VisPropertySet
Dim ItemToHide As Product
Dim NumberOfItems As Long
Dim SelectionList as String

Set selection1 = oTopProduct.Parent.Selection
Set visPropertySet1 = selection1.VisProperties
NumberOfItems = oTopProduct.Products.Count
SelectionList = ""

selection1.Clear
For i = 1 to NumberOfItems
set ItemToHide = oTopProduct.Products.Item(i)
selection1.Add ItemToHide
MsgBox "Added " & ItemToHide.PartNumber
SelectionList = SelectionList & chr(10) & selection1.Item(i).LeafProduct.PartNumber
next
MsgBox "Selection is " & SelectionList

Set visPropertySet1 = selection1.VisProperties
VisPropertySet1.SetShow 1 'HIDE
MsgBox "Selected components should be off"

For j = 1 to NumberOfItems
Set ItemToHide = oTopProduct.Products.Item(j)
k = ItemToHide.Products.Count
if k > 0 then
VisPropertySet1.SetShow 0 'SHOW
MsgBox "Entering " & ItemToHide.ReferenceProduct.PartNumber
selection1.Clear
Call TurnOff(ItemToHide.ReferenceProduct)
VisPropertySet1.SetShow 1 'HIDE
end if
next

End Sub

All the MsgBoxes show the right information, but the SetShow methods only work the first time around.

Thanks,
Jeff

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close