Looping though an array

Post Reply
hudatolah
Site Admin
Posts: 164
Joined: Thu Apr 04, 2013 8:10 pm
Are You a Headhunter?: Affirmative
Surfer?: Yes

Looping though an array

Post by hudatolah » Thu Oct 15, 2020 10:54 am

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.")
The Blackholesurfer. My surfboard has teeth.

hudatolah
Site Admin
Posts: 164
Joined: Thu Apr 04, 2013 8:10 pm
Are You a Headhunter?: Affirmative
Surfer?: Yes

Re: Looping though an array

Post by hudatolah » Thu Oct 09, 2025 4:21 pm

Python output:

Code: Select all

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

Code: Select all

List of values DEBUG: mymac
The Blackholesurfer. My surfboard has teeth.

Post Reply