Execute a variable assignment RRS feed

  • Question

  • Hello

    starting from  arraylines such as 

    Field[4] = "Box=Input;Info=OutputFile;action=D:\small-basic\Myfile"

    I need the variable "outputfile" equal to "D:\small-basic\Myfile" to be passed  to subroutines

    so starting from the array-line I need to encode something as 


    I don't know but I thought composing and executing a command from inside sb isn't possible.

    Another question is redirection such as in ksh "cmd< dir>output" , etc.


    Monday, February 11, 2019 8:41 PM


  • What you have is a 2D array.

    First note that \ is a special character when defining arrays as strings, it is an 'escape' character.  Also = and ; are special characters.

    To see how escape characters work create the arrays using [] notation.

    In your case:

    Field[4] = "Box=Input;Info=OutputFile;action=D:\small-basic\Myfile"



    which is not what yo want.  To get \ in an array it needs to be 'escaped' properly.

    Try the following - note \\ to espacpe the \ character:

    Field[4] = "Box=Input;Info=OutputFile;action=D:\\small-basic\\Myfile"

    Or, assign using [] notation.

    Field[4]["action"]= "D:\small-basic\Myfile"

    Or even use / which works in paths, but is not a special character for SB array strings

    Field[4] = "Box=Input;Info=OutputFile;action=D:/small-basic/Myfile"

    • Edited by litdev Monday, February 11, 2019 9:09 PM
    • Proposed as answer by Nonki Takahashi Monday, February 18, 2019 1:19 PM
    • Marked as answer by WhTurner33Editor Saturday, February 23, 2019 12:29 PM
    Monday, February 11, 2019 9:05 PM