Friday, June 8, 2012

USL 3.8.6

I'm back for a bit. I decided to add a few things that people had mentioned in the past, like an alternative for the counter-intuitive orif keyword and the lack of the ability to iterate an enumeration of object members. I decided to go ahead and add elif and elsif in respect to Python, Perl, and Ruby. I also made the --parse parameter known. Unless you disassembled USL, you probably would not have known about the ability to parse commands without starting the shell or running a script. To be honest, I have no clue as to why I didn't list that parameter in the help menu. And for Bruce, the only non-anonymous person to ever post a comment on my blog, I have created a way to iterate an enumeration of object members. I also changed the numeric datatype of numeric variables in order to deal with larger numbers. That about sums everything up. Here are some code samples.

Iterating an Enumeration of Object Members:

# Print all USL environment variables
for v in env.get_members
       say ${v}
endfor

# An object for demonstration
object o
       @hello = "Hello"
       @world = "World"

       method a
              say "In a()"
       end

       method b
              say "In b()"
       end

       method c
              say "In c()"
       end
end

# Print each value of all variables in an object
for v in o.get_variables
       say o.${v}
endfor

# Execute all methods in an object
for m in o.get_methods
       ! "o.${m}"
endfor
If you want an enumeration outside of a loop, you can create a list and add to the list as you iterate.

The elif and elsif keywords:

if 0 == 1
       say "This is false..."
elsif 1 == 0
       say "This is a Perl-esque 'else if' statement."
elif 1 == 1
       say "This is a Python-esque 'else if' statement."
endif
Other than these examples, there's not much else to show you. Here is how you use the --parse parameter:
./usl -p "for i in (10..1);out '${i}...';delay 1;endfor;say 'blastoff!'"
It's a cheesy example of a countdown, but it's pretty neat. The parse parameter is for when you don't feel like running the interactive shell or writing a script. I guess it could have other uses, but that's for you to decide.

Thanks for reading.

To download 3.8.6, you can visit any of the following links:
sourceforge
freecode
github