简体   繁体   English

是否可以在过程内部调用过程,如果可以,如何进行? (图灵)

[英]Is it possible to call a procedure inside a procedure, and if so, how? (Turing)

I've made a typewriter procedure for one of my programs in Turing, but I need it to be in a different font. 我在Turing中为我的一个程序制作了一个打字机程序,但是我需要它使用不同的字体。 I've tried Font.Draw, but since it's a procedure it wont let me use it inside the Typewriter Proc. 我已经尝试过Font.Draw,但是由于它是一个程序,所以我无法在Typewriter Proc中使用它。 Is there a way around this? 有没有解决的办法?

var chars : array char of boolean 
var font : int

font := Font.New("Pokemon GB:18")

proc TypewriterPrint(text : string) 
loop 
  for i : 1..length(text) 
  Input.KeyDown (chars) 
 if chars (KEY_ENTER) then 
    delay(50) 
    put text(i) .. 
 else
  delay(100) 
  put text(i) .. 
 end if 
 end for 
 put "" 
end loop 
end TypewriterPrint 

Font.Draw (TypewriterPrint("This will be printed like a typewriter"), 150, 150, font, black)

I've tried functions, but it doesn't work either. 我已经尝试过函数,但是也不起作用。

You would call it the same way you call a regular procedure. 您可以像调用常规过程一样调用它。 Just create the first procedure outside of everything, create a second procedure outside of the first, and call the first procedure from within the second one. 只需在所有内容之外创建第一个过程,在第一个过程之外创建第二个过程,然后从第二个过程中调用第一个过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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