People who are used to other Linux/Unix interpreted or scripting languages tend to want to use the backtick operator (e.g. `ls -al`) to run a command and store its output in a variable. In Gambas, you have to run the command, redirect its output to a temp file, and then load the temp file. Doing this a lot can be tedious, so use this function "Backtick()" in your code to simulate the backtick operator in other languages until Gambas gets this ability as well.
The Code
' Gambas class file PUBLIC FUNCTION Backtick(cmd AS String) AS String DIM result AS String DIM s AS String result = "" s = Temp() SHELL cmd & " >" & s WAIT TRY result = file.Load(s) TRY KILL s RETURN result END
PUBLIC SUB Button1_Click() PRINT Backtick("ls -al") END
-- ReinerHoffmann - 15 Oct 2004