私はこのコードを使用しています:
def copy_part_of_space(row,column,lenght):
#Copy String to Presentation Space (15)
#Prerequisite Connect Presentation Space
#Prerequisite function: connect_pcomm(presentation_space)
function_number = c_int(8)
data_string = create_string_buffer(lenght*2*2) #number of unicode char *2*2
lenght = c_int(lenght)
ps_position = c_int(((row - 1) * 80)+ column)
foo = hllapi(byref(function_number), data_string, byref(lenght), byref(ps_position))
data_string.value
return {{
0 : 'The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.',
1 : 'Your program is not connected to a host session.',
4 : 'The host presentation space contents were copied. The connected host presentation space was waiting for host response.',
5 : 'The host presentation space was copied. The keyboard was locked.',
9 : 'A system error was encountered.',
'x' : 'Undocumented error found. Run in circles.',
}.get(foo, 'x'),data_string.value}
アイデアは、端末からいくつかの情報をコピーすることです。関数は、ステータス情報 (ディクショナリと 0,1,4,5,9,x パラメータを使用) とコピーされた情報 (data_string.value を使用) を返す必要があります。
いくつかのテストを実行するために、上記の関数を使用するこのコードを使用していました。
for a in range(15,22):
print copy_part_of_space(a,7,8)
結果は次のとおりです。
set(['The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.', '36343581'])
set(['36343663', 'The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.'])
set(['The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.', '36343708'])
set(['36344673', 'The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.'])
set(['36344740', 'The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.'])
set(['The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.', '36344758'])
set(['36344869', 'The host presentation space contents were copied to the application program. The target presentation space was active, and the keyboard was unlocked.'])
ご覧のとおり、最初の行のように、ホスト アプリケーションからコピーされる前にステータス情報を取得することがあります。
しかし、2 行目のように、ステータス情報の前にコピーされた情報を取得することがあります。
私は情報を返すために使用することに慣れていないdict
ので、特に2つの変数を返そうとしているという事実と混ざり合ったときに、それが問題になる可能性があると思います.
なぜこれが起こっているのか誰でも説明できますか?
dict
リターンを渡す前に単純に を使用してリターン情報を変数に保存できることはわかっていますが、これはより洗練されたソリューションだと本当に思っていました-間違っていますか?