Files
HollywoodLibs/Examples/Helpers/HL_SizeString.hws
2025-05-03 10:00:37 +02:00

41 lines
1.2 KiB
Plaintext

/*
*********************************************
*** Helpers.hws Example : HL.SizeString() ***
*********************************************
*/
@INCLUDE "../../+Includes.hws"
@INCLUDE #INC_HELPERS
NPrint("HL.SizeString Example")
NPrint("---------------------\n")
; Suppose you have 40 character screen and a table with <n> entries with the
; fields <name> and <surnames>, you want to print a table with these
; informations:
; Initialize the table with some items
Local people =
{ { name = "Clark", surname = "Kent" },
{ name = "Peter", surname = "Parker" },
{ name = "Bruce", surname = "Wayne" } }
; Now we will print a nice table to the screen with the first column of 14
; characters and the second one of 22 (plus 3 separators):
; Header
NPrint("|" .. HL.SizeString("NAME", 14) .. "|" .. HL.SizeString("SURNAME", 22) .. "|")
; Contents
For Local i = 0 To 2
NPrint("|" .. HL.SizeString(people[i].name, 14) ..
"|" .. HL.SizeString(people[i].surname, 22) .. "|")
Next
; Exemple with string exceeding the available space
NPrint("|" .. HL.SizeString("This is an extremely long line!", 14) ..
"|" .. HL.SizeString("Another line, see how it works?", 22) .. "|")
NPrint("\n--- Left mouse button to quit ---")
WaitLeftMouse()