# In C-script, is the time symbol"t" treat as the system clock time or only S-cript block time

**URL:** <https://forum.plexim.com/t/in-c-script-is-the-time-symbol-t-treat-as-the-system-clock-time-or-only-s-cript-block-time/857>\
**Category:** PLECS\
**Tags:** c-script, simulation-time\
**Created:** [September 11, 2020, 6:55am UTC](https://forum.plexim.com/t/in-c-script-is-the-time-symbol-t-treat-as-the-system-clock-time-or-only-s-cript-block-time/857 "2020-09-11T06:55:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenjaminZZZ](https://avatars.discourse-cdn.com/v4/letter/b/9f8e36/32.png) [@BenjaminZZZ](https://forum.plexim.com/u/BenjaminZZZ)\
**Post date:** [September 11, 2020, 6:55am UTC](https://forum.plexim.com/t/in-c-script-is-the-time-symbol-t-treat-as-the-system-clock-time-or-only-s-cript-block-time/857/1 "2020-09-11T06:55:36Z")

</div>

For example, If we have a if function to let the csript block generates y=sin(2_pi_t) only during simulation time 0.3~0.5sec (Assume we have a simulation time for 1sec). In this 0.3~0.5 sec, the function will be generated. However, what is “t” in function represents, is it “0.3~0.5” or “0~0.2” (Since the C-script only runs for 0.2 sec).

---

<div class="post-metadata">

**Author:** ![Kris\_Eberle](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/kris_eberle/32/6_2.png) [@Kris\_Eberle](https://forum.plexim.com/u/Kris_Eberle)\
**Post date:** [September 11, 2020, 12:24pm UTC](https://forum.plexim.com/t/in-c-script-is-the-time-symbol-t-treat-as-the-system-clock-time-or-only-s-cript-block-time/857/2 "2020-09-11T12:24:06Z")

</div>

Hello,

There is a macro “CurrentTime” built into the C-Script engine that you can call in your logic and will get the current simulation time, with respect to t=0. So, 0.3 to 0.5 seconds in your case.

Regards,

Kris

---

<div class="post-metadata">

**Author:** ![BenjaminZZZ](https://avatars.discourse-cdn.com/v4/letter/b/9f8e36/32.png) [@BenjaminZZZ](https://forum.plexim.com/u/BenjaminZZZ)\
**Post date:** [September 11, 2020, 5:11pm UTC](https://forum.plexim.com/t/in-c-script-is-the-time-symbol-t-treat-as-the-system-clock-time-or-only-s-cript-block-time/857/3 "2020-09-11T17:11:06Z")

</div>

Hi, what if I want to use 0~0.2 instead of 0.3~0.5? Which is that I dont want to use the system clock, I want to use a independent C-script block which runs its own clock.

---

<div class="post-metadata">

**Author:** ![Bryan\_Lieblick](https://dub1.discourse-cdn.com/flex006/user_avatar/forum.plexim.com/bryan_lieblick/32/10_2.png) [@Bryan\_Lieblick](https://forum.plexim.com/u/Bryan_Lieblick)\
**Post date:** [September 14, 2020, 1:50pm UTC](https://forum.plexim.com/t/in-c-script-is-the-time-symbol-t-treat-as-the-system-clock-time-or-only-s-cript-block-time/857/4 "2020-09-14T13:50:39Z")

</div>

Would you be able to post a simple version of your model and script?

You could code a counter (if using fixed sample time) or integrator that would act as a “local clock” within the C-Script. For example, if you want to have a one-shot timer. Or you could reference simulation time, but use a time delay or store the time of the input event to calculate a time difference.
