Difference between revisions of "AGIWiki/Display text on screen"

Jump to navigation Jump to search
m
Text replacement - "</source>" to "</syntaxhighlight>"
m (Created page with "{{AGIWiki}} == Basics == Displaying text in AGI basically happens with commands print and display their variants. Print produces a message...")
 
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{AGIWiki}}
{{AGIWiki}}
<center>'''[[AGIWiki/Tutorials and Guides|Tutorials and Guides]]'''</center>


== Basics ==
== Basics ==
Line 15: Line 17:
A typical messagebox, displayed in the middle of the screen.
A typical messagebox, displayed in the middle of the screen.


<syntax type="C++">
<syntaxhighlight lang="cpp">
print("Hello world");
print("Hello world");
</syntax>
</syntaxhighlight>


Same but using ability to use #message .
Same but using ability to use #message .


<syntax type="C++">
<syntaxhighlight lang="cpp">
print(m1);
print(m1);


return();
return();
#message 1 "Hello world"
#message 1 "Hello world"
</syntax>
</syntaxhighlight>


This time in the #message-part has been put a [[AGIWiki/String|string]]. Note that string s1 has been defined '''before''' using print-command and #message can be also elsewhere within the logic than beneath return-command.
This time in the #message-part has been put a [[AGIWiki/String|string]]. Note that string s1 has been defined '''before''' using print-command and #message can be also elsewhere within the logic than beneath return-command.


<syntax type="C++">
<syntaxhighlight lang="cpp">
set.string(s1,"Hello world");
set.string(s1,"Hello world");
print(m1);
print(m1);
Line 36: Line 38:
return();
return();
#message 1 "%s1"
#message 1 "%s1"
</syntax>
</syntaxhighlight>


=== Print.v ===
=== Print.v ===
Line 42: Line 44:
Print.v provides a way for one print.v to display various messages. Once again it is important to define all modifiers before printing.
Print.v provides a way for one print.v to display various messages. Once again it is important to define all modifiers before printing.


<syntax type="C++">
<syntaxhighlight lang="cpp">
v40 = 2; /* Oh hai just sounds better than Hello */
v40 = 2; /* Oh hai just sounds better than Hello */
set.string(s1,"Hello world");
set.string(s1,"Hello world");
Line 50: Line 52:
#message 1 "%s1"
#message 1 "%s1"
#message 2 "Oh hai world"
#message 2 "Oh hai world"
</syntax>
</syntaxhighlight>


=== Print.at ===
=== Print.at ===
Line 56: Line 58:
Should a need for displaying messagebox elsewhere than middle arise, print.at is the solution.
Should a need for displaying messagebox elsewhere than middle arise, print.at is the solution.


<syntax type="C++">
<syntaxhighlight lang="cpp">
print.at(m2,1,20,10);
print.at(m2,1,20,10);
   
   
return();
return();
#message 2 "Oh hai world"
#message 2 "Oh hai world"
</syntax>
</syntaxhighlight>


=== Print.at.v ===
=== Print.at.v ===


And the variant print.at.v is bit tricky because it's syntax varies which software one uses, as stated in this [http://web.archive.org/web/20090427142144/http://www.agigames.com/forum/index.php?topic=7425.msg83109#msg83109 discussion] AGI Studio uses wrong arguments. However, examples for both WinAGI and AGI Studio are presented. It is unknown how QT AGI Studio handles this command though it is based on AGI Studio.
And the variant <code>print.at.v</code> is bit tricky because it's syntax varies which software one uses. AGI Studio uses wrong arguments. However, examples for both WinAGI and AGI Studio are presented. It is unknown how QT AGI Studio handles this command though it is based on AGI Studio.


==== WinAGI ====
==== WinAGI ====


With this command WinAGI is the IDE. The correct syntax being print.at.v(vA,byte ROW,byte COLUMN,byte MAXWIDTH);
With this command WinAGI is the IDE. The correct syntax being <code>print.at.v(vA,byte ROW,byte COLUMN,byte MAXWIDTH);</code>


<syntax type="C++">
<syntaxhighlight lang="cpp">
#message 2 "Hallo world"
#message 2 "Hallo world"
#message 1 "%s1"
#message 1 "%s1"
Line 77: Line 79:
if(f5){
if(f5){
   set.string(s1,"Hello world");
   set.string(s1,"Hello world");
 
  v40 = 1;
  v40 = 1;
  v41 = 1;
  v41 = 1;
  v42 = 20;
  v42 = 20;
  v43 = 10;
  v43 = 10;
 
  print.at.v(v40,1,20,10);
  print.at.v(v40,1,20,10);
}
}
return();
 
</syntax>
return();
</syntaxhighlight>


==== AGI Studio ====
==== AGI Studio ====
Line 92: Line 95:
AGI Studio's helpfile claims that command should be like this: <code>print.at.v(vA,vX,vY,vW);</code> but it only accepts <code>print.at.v(mA,vX,vY,vW);</code>. It is better to avoid using this command under AGI Studio altogether and compile it with WinAGI and with correct syntax.
AGI Studio's helpfile claims that command should be like this: <code>print.at.v(vA,vX,vY,vW);</code> but it only accepts <code>print.at.v(mA,vX,vY,vW);</code>. It is better to avoid using this command under AGI Studio altogether and compile it with WinAGI and with correct syntax.


<syntax type="C++">
<syntaxhighlight lang="cpp">
#message 2 "Hello world"
#message 2 "Hello world"
   
   
Line 105: Line 108:
   }
   }
   return();
   return();
</syntax>
</syntaxhighlight>


However, it will only print empty, yet right size messagebox. Weird, huh.
However, it will only print empty, yet right size messagebox. Weird, huh.
TrustedUser
2,147

edits

Navigation menu