Re: Newbie question

Welcome mac,

your code below should be more or less equal to:
(no chance of testing obviously)

def ae_6 session
pdu, pduLen = session.read(5).unpack(‘cN’)
buffer = session.read(pduLen)

calledAETitle, callingAETitle, itemType, itemLength =
buffer.unpack(‘x4A16A16x35Cxn’)

start = 72+itemLength
contextName=buffer.slice(72…start)

while start < pduLen
start = getNextPresentationContext(start, pdu[start…-1]) + 1
print “Finish = “,start-1,” outside proc\n”
end
end

def getNextPresentationContext(start, pdu)
it, itemLength, presContextId, itemType, itemLength =
pdu.unpack(‘CxnCx3Cxn’)

start = 12 + itemLength
abstractSyntax=pdu[12…start]
itemType=pdu[start]

while itemType == 64
itemLength=pdu[start+2…start+1].unpack(‘n’)[0]
transferSyntax=pdu[start+2…start+2+itemLength]

puts "id=#{presContextId}, AbstractSyntax =#{abstractSyntax},

TxSyntax=#{transferSyntax}"
start=start+2+itemLength+1
itemType=pdu[start]
end
return start-1
end

Hope you get the idea.

cheers

Simon