Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,4 @@
native("jvm")
module animation "1.0.0" {
import java.desktop "8";
}

View file

@ -0,0 +1,43 @@
import javax.swing {
JFrame,
JLabel,
Timer
}
import java.awt.event {
MouseAdapter,
MouseEvent,
ActionListener,
ActionEvent
}
shared void run() {
value initialText = "Hello World! ";
value label = JLabel(initialText);
variable value forward = true;
label.addMouseListener(object extends MouseAdapter() {
mouseClicked(MouseEvent? mouseEvent) =>
forward = !forward;
});
Timer(1k, object satisfies ActionListener {
shared actual void actionPerformed(ActionEvent? actionEvent) {
String left;
String right;
if(forward) {
left = label.text.last?.string else "?";
right = "".join(label.text.exceptLast);
} else {
left = label.text.rest;
right = label.text.first?.string else "?";
}
label.text = left + right;
}
}).start();
value frame = JFrame();
frame.defaultCloseOperation = JFrame.\iEXIT_ON_CLOSE;
frame.title = "Rosetta Code Animation Example";
frame.add(label);
frame.pack();
frame.visible = true;
}

View file

@ -0,0 +1,34 @@
DIM C AS STRING = "Hello World! ", SIZE AS USHORT = LEN(C)
DIM DIRECTION AS BYTE = 0
DIM AS INTEGER X, Y, BTNS
DIM BUTHELD AS BYTE = 0
SCREEN 12
DO
LOCATE 1, 1
PRINT C
GETMOUSE X, Y, , BTNS
IF BTNS <> 0 THEN
IF BUTHELD = 0 THEN 'remember if it was pressed, to not react
BUTHELD = 1 'every frame on the mouse being just held
IF (X >= 0 AND X < SIZE * 8) AND (Y >= 0 AND Y < 16) THEN
DIRECTION = 1 - DIRECTION
END IF
END IF
ELSE
BUTHELD = 0
END IF
IF INKEY = CHR(255) + CHR(107) THEN EXIT DO
IF DIRECTION = 0 THEN
C = RIGHT(C, 1) + LEFT(C, SIZE - 1)
ELSE
C = RIGHT(C, SIZE - 1) + LEFT(C, 1)
END IF
SLEEP 100, 1
LOOP

View file

@ -0,0 +1,33 @@
include arwen.ew
string hw = "Hello World! "
integer direction = 1
constant main = create(Window, "Animation", 0, 0, 20, 20, 300, 150, 0),
label = create(Label,hw,0,main,65,40,200,40,0),
MainTimer = createTimer()
setFont(label, "Verdana", 18, Normal)
removeStyle(main,WS_THICKFRAME+WS_MINIMIZEBOX+WS_MAXIMIZEBOX)
function mainHandler(integer id, integer msg, atom wParam, object lParam)
if msg=WM_SHOWWINDOW then
startTimer(MainTimer,main,160)
elsif msg=WM_TIMER then
if direction then
hw = hw[$]&hw[1..-2]
else
hw = hw[2..$]&hw[1]
end if
setText(label,hw)
elsif msg=WM_LBUTTONUP then
direction = 1-direction
elsif msg=WM_CHAR
and wParam=VK_ESCAPE then
closeWindow(main)
if id or object(lParam) then end if -- suppress warnings
end if
return 0
end function
setHandler({main},routine_id("mainHandler"))
WinMain(main, SW_NORMAL)