Register    Login    Forum    FAQ    PinSimDB.org

Board index » Resources » Resources Exchange




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: VBS Help : for LOOP and If statement?
 Post Posted: Tue May 12, 2015 10:09 pm 
Offline
User avatar

Joined: Mon Feb 27, 2012 10:39 am
Posts: 1867
I know how to do in in flash action script but can't wrap my head around if it is even possible in FP VBS.

I have 10 elements. they are all nicely set (variable, states and pf position) with a for loop :

Code:
Sub DropAllBaddies()
   dim x
      for x=1 to 11
         Execute"ST"&x&".MoveTo ST"&x&".tx, -30, ST"&x&".tz ,500"
         Execute "insert"&x&".frame 1"
         Execute "DT"&x&".PopDown"
      next
end sub


But the thing is that I need it to happen ONLY if a condition is met :

Roughly-------------------------------
Code:
for x=1 to 11
if (ST[x].isDead=false )then......



How would it be written to work in VBS?

_________________
add me to SKYPE : steve.paradis49


Top 
 Profile  
 
 Post subject: Re: VBS Help : for LOOP and If statement?
 Post Posted: Wed May 13, 2015 2:34 pm 
Offline
User avatar

Joined: Fri Sep 09, 2011 9:14 pm
Posts: 142
Did you tried with Eval?

Code:
Sub DropAllBaddies()
   Dim x
   For x = 1 to 11
      If Eval("ST" & x).isDead = false Then
         Execute "ST" & x & ".MoveTo ST" & x & ".tx, -30, ST" & x & ".tz ,500"
         Execute "insert" & x & ".frame 1"
         Execute "DT" & x & ".PopDown"
      End If
   Next
End Sub


Eval works similar than Execute, and I'm not completely sure about the differences.

As a side note, I prefer to use Eval because I think it's cleaner this:

Eval("DT" & x).PopDown

Than this:

Execute "DT" & x & ".PopDown"

Only the variable part has to be an string inside the eval.

And so, I reserve the Execute when the full method depends on a String, which is so unusual (I used that on the Multi-Light demo, assigning methods as strings into the Hash)

It would be:

Code:
Sub DropAllBaddies()
   Dim i : For i = 1 to 11
      If Eval("ST" & i).isDead = false Then
         Dim x, z
         x = Eval("ST" & i).tx : z = Eval("ST" & i).tz
         Eval("ST" & i).MoveTo x, -30, z, 500
         Eval("insert" & i).frame 1
         Eval("DT" & i).PopDown
      End If
   Next
End Sub


But both ways are viable.


Last edited by Wecoc on Wed May 13, 2015 2:54 pm, edited 1 time in total.

Top 
 Profile  
 
 Post subject: Re: VBS Help : for LOOP and If statement?
 Post Posted: Wed May 13, 2015 2:51 pm 
Offline
User avatar

Joined: Mon Feb 27, 2012 10:39 am
Posts: 1867
didn't know eval could be mixed within an if statement but that make sens. will test it tonight thx a lot wecoc

_________________
add me to SKYPE : steve.paradis49


Top 
 Profile  
 
 Post subject: Re: VBS Help : for LOOP and If statement?
 Post Posted: Thu May 14, 2015 6:45 am 
Offline
User avatar

Joined: Mon Feb 27, 2012 10:39 am
Posts: 1867
actually the eval look strangely a lot more flash actionscript 2 which is great!

your line : Eval("DT" & x).PopDown
in flash AS2 : this["DT" + x].PopDown

_________________
add me to SKYPE : steve.paradis49


Top 
 Profile  
 
 Post subject: Re: VBS Help : for LOOP and If statement?
 Post Posted: Thu May 14, 2015 11:16 pm 
Offline
User avatar

Joined: Mon Feb 27, 2012 10:39 am
Posts: 1867
worked like a charm, thx a lot!

_________________
add me to SKYPE : steve.paradis49


Top 
 Profile  
 
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 5 posts ] 

Board index » Resources » Resources Exchange


Who is online

Users browsing this forum: No registered users and 7 guests

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to: