How to make a file run if a void has undefined coordinates?

Hello! (Sorry about the title, I didn’t know what to call it…)

I’m trying to get a vbs script to load (debugging purposes.) but since StartClip is a void, not a bool, the ‘if’ statement won’t work. Is there another alternative?

the error code: ‘error CS0029: Cannot implicitly convert type void' to bool’’

I’m making an exception handler, by the way. So if the PlayLengthLoop (The script’s name.) has (0.0f, 0.0f) as a start and end loop, the game should open the test.vbs file. (Eventually, I’ll make it so that it would load another level to prevent the Unity Editor and the built game from crashing.)

using UnityEngine;
using System.Collections;
using System.Diagnostics;

public class PlayLengthLoop : MonoBehaviour {

    public AudioClip audioClip;

    void Start()
    {
       //
		StartClip(0.0f,0.0f);

    }

    void StartClip(float timeStart, float timeEnd)
    {
       audio.clip = audioClip;
       audio.time = timeStart;
       audio.Play();
       StartCoroutine(DelaySoundStop(timeEnd));
    }

    IEnumerator DelaySoundStop(float timeEnd)
    {
       while(audio.time < timeEnd)
         yield return null;
	   StartClip(0.0f,0.0f);
       //Add your own times here !
		if (StartClip(0.0f,0.0f));
		System.Diagnostics.Process.Start(@"C:\Users\-----\Desktop	est.vbs");
       

    }
}

what you’re doing is, err, unconventional but you’d need to change StartClip() to something like this:

private bool StartClip(float timeStart, float timeEnd)
{
    audio.clip = audioClip;
    audio.time = timeStart;
    audio.Play();
    StartCoroutine(DelaySoundStop(timeEnd));

    return ((timeStart == 0.0f) && (timeEnd == 0.0f))
}

and lose the semicolon on line 26.

ALTHOUGH why on earth you’re calling it from the coroutine that it starts is rather mysterious… on re-reading your question, if you’re trying to make an exception handler this is not how you’d do it… to look try/catch/throw/finally/etc.