# Sample project scripts for Ignition 8.1

**URL:** <https://forum.inductiveautomation.com/t/sample-project-scripts-for-ignition-8-1/75679>\
**Category:** Ignition\
**Tags:** ignition81, perspective, scripting\
**Created:** [June 29, 2023, 1:14am UTC](https://forum.inductiveautomation.com/t/sample-project-scripts-for-ignition-8-1/75679 "2023-06-29T01:14:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sameer\_Ambegaonkar](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Sameer\_Ambegaonkar](https://forum.inductiveautomation.com/u/Sameer_Ambegaonkar)\
**Post date:** [June 29, 2023, 1:14am UTC](https://forum.inductiveautomation.com/t/sample-project-scripts-for-ignition-8-1/75679/1 "2023-06-29T01:14:11Z")

</div>

Hi,

New to Ignition.

Appreciate if there is any source or sample functions that can be done and way to do it in the scripting project library. Need to write functions that would read tag values, process them and return the results.

Regards,  
Sameer

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [June 29, 2023, 2:36am UTC](https://forum.inductiveautomation.com/t/sample-project-scripts-for-ignition-8-1/75679/2 "2023-06-29T02:36:48Z")

</div>

In this case, I create a function that sends target values based on input params.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/2/22471f9a1542ba561e31b20ec2c836f433bbe6d7.png)

Then call this function in tag change script.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/7/87307dfe5235e31b7010126d7648a387bf006d92.png)

Make sure to set the Gateway Scripting Project.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/2/f270377b118481b089643ee5c8b237e5b5fc97a6.png)

---

<div class="post-metadata">

**Author:** ![Sameer\_Ambegaonkar](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Sameer\_Ambegaonkar](https://forum.inductiveautomation.com/u/Sameer_Ambegaonkar)\
**Post date:** [June 29, 2023, 5:02am UTC](https://forum.inductiveautomation.com/t/sample-project-scripts-for-ignition-8-1/75679/3 "2023-06-29T05:02:33Z")

</div>

Thanks for the reply @nideyijuyidong

Writing to a tag through the script. But the tag value is in error.

 ![Ignition](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/5/5530937d3a883edc9b2eed8a4ecdade606eb9484.png)

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [June 29, 2023, 5:17am UTC](https://forum.inductiveautomation.com/t/sample-project-scripts-for-ignition-8-1/75679/4 "2023-06-29T05:17:20Z")

</div>

Because _system.tag.readBlocking_ return a list of Qualified objects . Use _val[0].value_ instead.

> - Returns
> 
> List - A list of QualifiedValue objects corresponding to the Tag paths. See [Scripting Object Reference](https://docs.inductiveautomation.com/display/DOC81/Scripting+Object+Reference#ScriptingObjectReference-QualifiedValue).

---

<div class="post-metadata">

**Author:** ![Sameer\_Ambegaonkar](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Sameer\_Ambegaonkar](https://forum.inductiveautomation.com/u/Sameer_Ambegaonkar)\
**Post date:** [June 29, 2023, 5:49am UTC](https://forum.inductiveautomation.com/t/sample-project-scripts-for-ignition-8-1/75679/5 "2023-06-29T05:49:05Z")

</div>

That worked. Appreciate you help @nideyijuyidong

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 29, 2023, 6:35am UTC](https://forum.inductiveautomation.com/t/sample-project-scripts-for-ignition-8-1/75679/6 "2023-06-29T06:35:38Z")

</div>

If I may, 2 ways of making that script a bit simpler:

```python
if season_mode_code in [0, 1, 2]:
    JiJieMode = 1 if season_mode_code == 1 else 0
    GuoDuMode = 1 if season_mode_code == 2 else 0
    # tag write code

# OR

JiJieMode = 0
GuoDuMode = 0
if season_mode_code == 1:
    JiJieMode = 1
elif season_mode_code == 2:
    GuoDuMode = 1
else:
    return
# tag write code

```

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [June 29, 2023, 8:11am UTC](https://forum.inductiveautomation.com/t/sample-project-scripts-for-ignition-8-1/75679/7 "2023-06-29T08:11:46Z")

</div>

Yes, that could be easier. I keep them in this style, because it follows the format of the logic document(about how the equipments work). my unprofessional programer colleagues would easily understand this in the future.  
Haha, I hope my colleagues who have never touched Python can at least understand what the script is doing.
