Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,4 +1,5 @@
---
category:
- String manipulation
- Simple
note: Basic language learning

View file

@ -0,0 +1,36 @@
program Project1;
uses
System.SysUtils;
var
Template : string;
Marker : string;
Description : string;
Value : integer;
Output : string;
begin
// StringReplace can be used if you are definitely using strings
// http://docwiki.embarcadero.com/Libraries/XE7/en/System.SysUtils.StringReplace
Template := 'Mary had a X lamb.';
Marker := 'X';
Description := 'little';
Output := StringReplace(Template, Marker, Description, [rfReplaceAll, rfIgnoreCase]);
writeln(Output);
// You could also use format to do the same thing.
// http://docwiki.embarcadero.com/Libraries/XE7/en/System.SysUtils.Format
Template := 'Mary had a %s lamb.';
Description := 'little';
Output := format(Template,[Description]);
writeln(Output);
// Unlike StringReplace, format is not restricted to strings.
Template := 'Mary had a %s lamb. It was worth $%d.';
Description := 'little';
Value := 20;
Output := format(Template,[Description, Value]);
writeln(Output);
end.

View file

@ -0,0 +1,2 @@
x = "little"
IO.puts "Mary had a #{x} lamb"

View file

@ -0,0 +1,2 @@
x = "little"
println["Mary had a $x lamb."]

View file

@ -0,0 +1,4 @@
main: func {
X := "little"
"Mary had a #{X} lamb" println()
}