Skip to content

Commit

Permalink
Update "not working" examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Sep 5, 2023
1 parent 74649ef commit 5a2ef79
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1,135 deletions.
9 changes: 4 additions & 5 deletions resources/examples/notworking/globals.c3
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
module globals;


const string CLICK_ME = "Click Me";
var uint counter = 0;
const String CLICK_ME = "Click Me";
uint counter = 0;

fn void clickedme(GtkButton *o, void *d)
{
(GtkLabel*)(d).set_text(string.format("You clicked me %d times", ++counter));
}

int main(int argc as string[] argv)
fn void main(String[] argv)
{
gtk::init(&argc, &argv);

GtkWindow *win = gtk::windowCreate(GtkWindow::TOPLEVEL);
GtkWindow *win = gtk::windowCreate(GtkWindow.TOPLEVEL);
win.set_title(CLICK_ME);

GtkButton *button = gtk::buttonCreateWithLabel(CLICK_ME);
Expand All @@ -32,5 +32,4 @@ int main(int argc as string[] argv)

win.showAll();
gtk::main();
return 0;
}
8 changes: 4 additions & 4 deletions resources/examples/notworking/http.c3
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ fn int main(void)
{
Curl curl;

catch (e = curl.init())
if (catch e = curl.init())
{
printf("Failed to create new curl: %s\n", e.message);
io::printfn("Failed to create new curl: %s\n", e);
exit(FAILURE);
}

curl.setopt(URL, "http://www.rosettacode.org/");
curl.setopt(FOLLOWLOCATION, 1);

catch (e = curl.perform())
if (catch err = curl.perform())
{
printf("Error making request: %s\n", e.message);
io::printfn("Error making request: %s\n", e);
exit(FAILURE);
}

Expand Down
10 changes: 5 additions & 5 deletions resources/examples/notworking/madlibs.c3
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import regex, stdio;
fn void main()
{
printn("Enter a story template, terminated by an empty line:");
VarString story = "";
while (1)
String story = "";
while (try String line = stdin().readline().strip())
{
VarString line = stdin.readln().strip() else break;

story = story.append(line);
story = story.append("\n");
}

Regex r;

r.initWithOptions("<.+?>", RegexOpt.GLOBAL) else unreachable;
r.initWithOptions("<.+?>", RegexOpt.GLOBAL)!!;
defer r.destroy();

foreach (RegexMatch* match : r.match(story))
{
VarString s = match.string;
printf("Enter a value for '%s': ", s[1..^2]);
string word = stdin.readln().strip() else return;
String word = stdin().readline().strip()!;
story = story.replace(s, word);
}

Expand Down
Loading

0 comments on commit 5a2ef79

Please sign in to comment.