Page 1 of 1

Looping though an array

Posted: Thu Oct 15, 2020 10:54 am
by hudatolah
First set computersystem=mymac as a value and export computersystem. Then run one of these

Code: Select all

if computersystem then
                        valuerow:= [];
			valuerow := computersystem;
            for f in valuerow do
                        list.append(mylist, valuerow);
			log.info("List of values DEBUG: %mylist%");
             end for; 
		end if;
Bash:

Code: Select all

computersystem = $computersystem
mylist = []

if computersystem:
    valuerow = [computersystem]
    for f in valuerow:
        mylist.append(f)
        print(f"List of values DEBUG: {mylist}")


Python:

Code: Select all

computersystem = "mymac"
mylist = []

if computersystem:
    valuerow = [computersystem]
    for f in valuerow:
        mylist.append(f)
        print(f"List of values DEBUG: {mylist}")
Or read it from the env:

Code: Select all

import os

# Read the environment variable "computersystem"
computersystem = os.getenv("computersystem")

if computersystem:
    valuerow = [computersystem]
    mylist = []
    for f in valuerow:
        mylist.append(f)
        print(f"List of values DEBUG: {mylist}")
else:
    print("Environment variable 'computersystem' is not set.")

Re: Looping though an array

Posted: Thu Oct 09, 2025 4:21 pm
by hudatolah
Python output:

Code: Select all

List of values DEBUG: ['mymac']
Shell script output:

Code: Select all

List of values DEBUG: mymac