• 0

How to energize multiople StaticIO given only when a certain DIO is ON.


Arctic

Question

I don't have much programming experience, but would like to energize and run script only when IO8 is ON, if not the script wont run but will continue scanning IO8.

clear()
if(!('StaticIO' in this)) throw "Please open the StaticIO instrument";
var IO=7

print("Running StaticIO script");
StaticIO.Channel1.Mode.text = "IOs";
StaticIO.Channel0.Mode.text = "IOs";
var dio8=StaticIO.Channel1.DIO8.Input.value
StaticIO.run()

while( dio8="1" ){ //DIO 8


// Loop at .3s rate

        for(var c = 0; c <= IO; c++){ 
            StaticIO.Channel0.DIO[c].text = "1";
            wait(.3);
            StaticIO.Channel0.DIO[c].text = "0";
            wait(.3);
        }
        for(var c = IO; c > 0; c--){
            StaticIO.Channel0.DIO[c-1].text = "1";
            wait(.3);
            StaticIO.Channel0.DIO[c-1].text = "0";
            wait(.3);}
        else if (dio8="0"){
        END
        }
}

//Error in: "file 2" line: 28 "else if (dio8="0"){END}"
//SyntaxError: Parse error

 

 

Edited by Arctic
Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hi @Arctic

See the following:

clear()
if(!('StaticIO' in this)) throw "Please open the StaticIO instrument";
const IO = 7
const delay = 0.3

print("Running StaticIO script");
for(var c = 0; c <= IO; c++){ 
    StaticIO.Channel0.DIO[c].Mode.text = "Switch"
}
StaticIO.run()

while(wait()){ // while script not stopped
    if(StaticIO.Channel1.DIO8.Input.value == 1){
        for(var c = 0; c <= IO; c++){ 
            StaticIO.Channel0.DIO[c].text = "1";
            StaticIO.config(); // apply changes now
            if(!wait(delay)) return; // exit on script stop
            StaticIO.Channel0.DIO[c].text = "0";
            StaticIO.config();
            if(!wait(delay)) return;
        }
        for(var c = IO; c > 0; c--){
            StaticIO.Channel0.DIO[c-1].text = "1";
            StaticIO.config();
            if(!wait(delay)) return;
            StaticIO.Channel0.DIO[c-1].text = "0";
            StaticIO.config();
            if(!wait(delay)) return;
       }
    }
}

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now