<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Codesys Tools&gt;Scripting&gt; Excute script file</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/6bdb950605/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/6bdb950605/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/6bdb950605/</id><updated>2020-02-27T14:52:05.515000Z</updated><subtitle>Recent posts to Codesys Tools&gt;Scripting&gt; Excute script file</subtitle><entry><title>Codesys Tools&gt;Scripting&gt; Excute script file</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/6bdb950605/?limit=25#0fdf" rel="alternate"/><published>2020-02-27T14:52:05.515000Z</published><updated>2020-02-27T14:52:05.515000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.come1dd53046926dc6045425052685d4ff67e00016d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; M.Schaber&lt;/p&gt;
&lt;p&gt;Currently, it is not possible to give parameters to scripts which are executed during the UI.&lt;/p&gt;
&lt;p&gt;We have an improvement &lt;a class="" href="http://jira.3s-software.com/browse/CDS-42003" rel="nofollow"&gt;CDS-42003&lt;/a&gt; in our tracker to improve this (but it is not yet scheduled).&lt;/p&gt;
&lt;p&gt;However, it is possible to pass arguments to scripts which are executed via the codesys command line interface, see the online help for a description.&lt;/p&gt;
&lt;p&gt;Additionally, the script itsself can use system.ui methods to ask the user interactively for values like project names. I did attach a test script which shows the possible dialogs.&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="https://forum.codesys.com//download/file.php?id=945" rel="nofollow"&gt;System_UI_Test.py &lt;span&gt;&lt;span&gt;[2.75 KiB]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Codesys Tools&gt;Scripting&gt; Excute script file</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/6bdb950605/?limit=25#4d83" rel="alternate"/><published>2020-02-27T14:52:04.820000Z</published><updated>2020-02-27T14:52:04.820000Z</updated><author><name>Rahied</name><uri>https://forge.codesys.com/u/rahied/</uri></author><id>https://forge.codesys.com59b5e3a2b07f3b1c4718d934296e175d88b46fd4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;is somting like this possible &lt;/p&gt;
&lt;p&gt;#!/usr/bin/env python&lt;br/&gt;
# Years till 100&lt;br/&gt;
import sys&lt;/p&gt;
&lt;p&gt;name = sys.argv&lt;span&gt;[1]&lt;/span&gt;&lt;br/&gt;
age = int(sys.argv&lt;span&gt;[2]&lt;/span&gt;)&lt;br/&gt;
diff = 100 - age&lt;/p&gt;
&lt;p&gt;print 'Hello', name + ', you will be 100 in', diff, 'years!'&lt;/p&gt;
&lt;p&gt;Give this program a name of years.py, be sure to give it execute permission and then run it with the following command: &lt;/p&gt;
&lt;p&gt;./years.py Joe 25&lt;/p&gt;
&lt;p&gt;Maybe this is a beter exsample what i try to build.&lt;/p&gt;
&lt;p&gt;import sys&lt;/p&gt;
&lt;p&gt;ProjectName = sys.argv&lt;span&gt;[0]&lt;/span&gt;&lt;br/&gt;
ProjectNumber = sys.argv&lt;span&gt;[1]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;#ProjectName ="Frukar, Barendrecht" &lt;br/&gt;
#ProjectNumber ="121079" &lt;/p&gt;
&lt;p&gt;#Vanaf deze regel hoef er niks meer worden aangepast of veranderd worden.&lt;br/&gt;
#########################################################################################################################################################################################################&lt;br/&gt;
#########################################################################################################################################################################################################&lt;br/&gt;
#########################################################################################################################################################################################################&lt;br/&gt;
# Clean up any open project:&lt;br/&gt;
if projects.primary:&lt;br/&gt;
    projects.primary.close()  &lt;br/&gt;
print("--- CleanUp finished. ---")&lt;br/&gt;
#########################################################################################################################################################################################################&lt;br/&gt;
#########################################################################################################################################################################################################&lt;br/&gt;
#########################################################################################################################################################################################################&lt;br/&gt;
#Make the directory for the Automation department.&lt;br/&gt;
ProjectPathAutomation ='4. Automation\2. PLC\1. CoDeSys\2. Project\'&lt;br/&gt;
NewProjectName = ProjectName.replace(',', '&lt;em&gt;')&lt;br/&gt;
CreateProjectName = "%s&lt;/em&gt;%s" % (NewProjectName, ProjectNumber)&lt;br/&gt;
AutomationPath = "L:\" + ProjectName + "\" + ProjectNumber + "\" + ProjectPathAutomation + CreateProjectName + ".project"&lt;br/&gt;
PROJECT = r"" + AutomationPath&lt;br/&gt;
print("--- The project create en save it on the next location : " + PROJECT + ".---")&lt;br/&gt;
#Make the directory for the Electro department.&lt;br/&gt;
ProjectPathElectro = '3. Elektro\2. PLC IO\'&lt;br/&gt;
ElectroPath = "L:\" + ProjectName + "\" + ProjectNumber + "\" + ProjectPathElectro + "Import.txt"&lt;br/&gt;
print("--- The next import location are by use :" + ElectroPath + ".---")&lt;br/&gt;
#########################################################################################################################################################################################################&lt;br/&gt;
#########################################################################################################################################################################################################&lt;br/&gt;
#########################################################################################################################################################################################################&lt;br/&gt;
# Import Path&lt;br/&gt;
F = open(r"" + ElectroPath , "r")&lt;br/&gt;
# Library Path&lt;br/&gt;
L = open(r"C:\Codesys Python Script\Library Import.txt", "r")&lt;br/&gt;
# Symbols Name Path&lt;br/&gt;
S = open(r"C:\Codesys Python Script\Library Import.txt", "r")&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>