简体   繁体   中英

Return values from subprogram

I've created a subprogram called DEVICE_ON in which I've defined some of these statements

 if j == 2: print('shutdown') # Run command. ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(shutdown) var_colonna_2=data_array[i][j] return var_colonna_2

var_colonna_2 is a string value (could be "X" or "V") and in this subprogram I have 8 return value (one for each var_colonna)

Now in the main programm I'm calling another subprogramm defined as:

CHECK_TEST(var_colonna_1, var_colonna_2, var_colonna_3, var_colonna_4, var_colonna_5, var_colonna_6, var_colonna_7, var_colonna_8)

this CHECK_TEST of course is executed after the DEVICE_ON. So basically In the main programm I have something like:

DEVICE_ON(ssh,data_array, i, j)

CHECK_TEST(var_colonna_1,var_colonna_2, var_colonna_3, var_colonna_4, var_colonna_5, var_colonna_6, var_colonna_7, var_colonna_8)

I was expecting that, since in DEVICE_ON, I've defined the return value for var_colonna_x (x=1 to 8), automatically the value of each var_colonna was updated and received from CHECK_TEST for internal computation,but right now it always sees 0.

I've also tried with the debug.It seems that the values are passed, but I still don't get why they are not seen in the next subprogram.

return_picture_debug_mode

I've understand where my mistake was. Basically the retur function is ok but in the main I was missing something like:

var_colonna_1=CHECK_TEST(var_colonna_1, var_colonna_2, var_colonna_3, var_colonna_4, var_colonna_5, var_colonna_6, var_colonna_7, var_colonna_8)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM