sub push(x$) queue$ = queue$ + x$ + "#" end sub sub pop$() local i, r$ if queue$ <> "" then i = instr(queue$, "#") if i then r$ = left$(queue$, i-1) stack$ = right$(queue$, len(queue$) - i) else r$ = queue$ queue$ = "" end if return r$ else print "--Queue is empty--" end if end sub sub empty() return queue$ = "" end sub // ======== test ======== for n = 3 to 5 print "Push ", n : push(str$(n)) next print "Pop ", pop$() print "Push ", 6 : push(str$(6)) while(not empty()) print "Pop ", pop$() wend print "Pop ", pop$()