Difference between revisions of "Documentation/DevGuide/Basic/Screen IO Functions"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (FINAL VERSION FOR L10N)
m
 
Line 12: Line 12:
 
* The <code>Print</code> statement displays strings or numeric expressions in a dialog. Multiple expressions are separated by commas that result in a tab distance between the expressions, or semicolons that result in a space between the expressions. For example:
 
* The <code>Print</code> statement displays strings or numeric expressions in a dialog. Multiple expressions are separated by commas that result in a tab distance between the expressions, or semicolons that result in a space between the expressions. For example:
  
 +
<source lang="oobas">
 
   e = 2.718
 
   e = 2.718
 
   Print e                  ' displays "2.718"
 
   Print e                  ' displays "2.718"
 
   Print "e =" ; e          ' displays "e = 2.718"
 
   Print "e =" ; e          ' displays "e = 2.718"
 
   Print "e =" , e          ' displays "e = 2.718"
 
   Print "e =" , e          ' displays "e = 2.718"
 
+
</source>
  
 
* The MsgBox function displays a dialog box containing a message. Additionally, the caption of the dialog, buttons, such as '''OK''', '''Cancel''', '''Yes''' and '''No''', and icons, such as question mark and exclamation mark, that are to be displayed are specified. The result then can be evaluated. For example:
 
* The MsgBox function displays a dialog box containing a message. Additionally, the caption of the dialog, buttons, such as '''OK''', '''Cancel''', '''Yes''' and '''No''', and icons, such as question mark and exclamation mark, that are to be displayed are specified. The result then can be evaluated. For example:
  
 +
<source lang="oobas">
 
   ' display a message box with an exclamation mark and OK and Cancel buttons
 
   ' display a message box with an exclamation mark and OK and Cancel buttons
 
   ret& = Msgbox ("Changes will be lost. Proceed?", 48 + 1, "Warning")
 
   ret& = Msgbox ("Changes will be lost. Proceed?", 48 + 1, "Warning")
Line 25: Line 27:
 
   ' show user's selection. 1 = OK, 2 = Cancel
 
   ' show user's selection. 1 = OK, 2 = Cancel
 
   Print ret&
 
   Print ret&
 
+
</source>
  
 
* The <code>InputBox</code> function displays a prompt in a dialog where the user can input text. The input is assigned to a variable. For example:
 
* The <code>InputBox</code> function displays a prompt in a dialog where the user can input text. The input is assigned to a variable. For example:
  
 +
<source lang="oobas">
 
   ' display a dialog with "Please enter a phrase:" and "Dear User" as caption
 
   ' display a dialog with "Please enter a phrase:" and "Dear User" as caption
 
   ' the dialog contains an edit control and the text entered by the user
 
   ' the dialog contains an edit control and the text entered by the user
 
   ' is stored in UserText$ when the dialog is closed with OK. Cancel returns ""  
 
   ' is stored in UserText$ when the dialog is closed with OK. Cancel returns ""  
 
   UserText$ = InputBox( "Please enter a phrase:", "Dear User" )
 
   UserText$ = InputBox( "Please enter a phrase:", "Dear User" )
 +
</source>
  
 
{{PDL1}}
 
{{PDL1}}
  
 
[[Category:Documentation/Developer's Guide/Basic and Dialogs]]
 
[[Category:Documentation/Developer's Guide/Basic and Dialogs]]

Latest revision as of 09:43, 22 October 2009



Basic provides statements and functions to display information on the screen or to get information from the user:

  • The Print statement displays strings or numeric expressions in a dialog. Multiple expressions are separated by commas that result in a tab distance between the expressions, or semicolons that result in a space between the expressions. For example:
  e = 2.718
  Print e                  ' displays "2.718"
  Print "e =" ; e          ' displays "e = 2.718"
  Print "e =" , e          ' displays "e = 2.718"
  • The MsgBox function displays a dialog box containing a message. Additionally, the caption of the dialog, buttons, such as OK, Cancel, Yes and No, and icons, such as question mark and exclamation mark, that are to be displayed are specified. The result then can be evaluated. For example:
  ' display a message box with an exclamation mark and OK and Cancel buttons
  ret& = Msgbox ("Changes will be lost. Proceed?", 48 + 1, "Warning")
 
  ' show user's selection. 1 = OK, 2 = Cancel
  Print ret&
  • The InputBox function displays a prompt in a dialog where the user can input text. The input is assigned to a variable. For example:
  ' display a dialog with "Please enter a phrase:" and "Dear User" as caption
  ' the dialog contains an edit control and the text entered by the user
  ' is stored in UserText$ when the dialog is closed with OK. Cancel returns "" 
  UserText$ = InputBox( "Please enter a phrase:", "Dear User" )
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages