langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,42 @@
declare
[QTk] = {Module.link ['x-oz://system/wp/QTk.ozf']}
proc {Main}
MaxValue = 1000
NumberWidget
GUI = lr(
numberentry(init:1 min:0 max:MaxValue handle:NumberWidget)
button(text:"Increase"
action:proc {$}
OldVal = {NumberWidget get($)}
in
{NumberWidget set(OldVal+1)}
end)
button(text:"Random"
action:proc {$}
if {Ask "Reset to random?"} then
Rnd = {OS.rand} * MaxValue div {OS.randLimits _}
in
{NumberWidget set(Rnd)}
end
end)
)
Window = {QTk.build GUI}
in
{Window show}
end
fun {Ask Msg}
Result
Box = {QTk.build
td(message(init:Msg)
lr(button(text:"Yes" action:proc {$} Result=true {Box close} end)
button(text:"No" action:proc {$} Result=false {Box close} end)
))}
in
{Box show}
{Box wait}
Result
end
in
{Main}

View file

@ -0,0 +1,56 @@
declare
[Roads] = {Module.link ['x-ozlib://wmeyer/roads/Roads.ozf']}
MaxValue = 1000
fun {Start Session}
{Page 0}
end
fun {Page Val}
html(
body(
%% numerical input with an HTML form
local NewVal in
form(
{NumberInput Val NewVal}
input(type:submit)
method:post
action:fun {$ _}
{Page NewVal}
end
)
end
%% link with button functionality
a("Increase"
href:fun {$ _}
{Page Val+1}
end)
" "
%% another "button-link"
a("Random"
href:fun {$ S}
p("Reset to random? - "
a("Yes" href:fun {$ _}
Rnd = {OS.rand} * MaxValue div {OS.randLimits _}
in
{Page Rnd}
end)
" "
a("No" href:fun {$ _} {Page Val} end)
)
end)
))
end
%% a "formlet", managing input of an integer value
fun {NumberInput OldVal NewVal}
input(type:text
validate:int_in(0 MaxValue)
value:{Int.toString OldVal}
bind:proc {$ Str} NewVal = {String.toInt Str.escaped} end
)
end
in
{Roads.registerFunction 'start' Start}
{Roads.run}

View file

@ -0,0 +1,28 @@
Enumeration
#StringGadget
#Increment
#Random
EndEnumeration
If OpenWindow(0,#PB_Ignore,#PB_Ignore,180,50,"PB-GUI",#PB_Window_SystemMenu)
StringGadget(#StringGadget,5,5,170,20,"",#PB_String_Numeric)
ButtonGadget(#Increment,5,25,80,20, "Increment")
ButtonGadget(#Random, 90,25,80,20, "Random")
Repeat
Event=WaitWindowEvent()
If Event=#PB_Event_Gadget
Select EventGadget()
Case #Increment
CurrentVal=Val(GetGadgetText(#StringGadget))
SetGadgetText(#StringGadget,Str(CurrentVal+1))
Case #Random
Flag=#PB_MessageRequester_YesNo
Answer=MessageRequester("Randomize","Are you sure?",Flag)
If Answer=#PB_MessageRequester_Yes
SetGadgetText(#StringGadget,Str(Random(#MAXLONG)))
EndIf
EndSelect
EndIf
Until Event=#PB_Event_CloseWindow
CloseWindow(0)
EndIf

View file

@ -0,0 +1,43 @@
dim dd$(5) ' drop down box
for i = 1 to 5
dd$(i) = "Drop ";i
next i
value$ = "1234"
notes$ = "Rosetta Code
is good"
bf$ = "<SPAN STYLE='font-family:arial; font-weight:700; font-size:12pt'>"
[screen]
cls
html bf$;"<center><TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 bgcolor=wheat>"
html "<TR align=center BGCOLOR=tan><TD colspan=2>Rosetta Code</TD></TR><TR>"
html "<TD align=right bgcolor=tan>Value:</TD><TD>"
textbox #val,value$,5
html "</TD></TR><TR><TD bgcolor=tan align=right>Radio</TD><TD>"
radiogroup #rdo,"1,2,3,4,5",rdo$
#rdo horizontal(1)
html "</TD></TR><TR><TD bgcolor=tan align=right>Drop Down</TD><TD>"
listbox #dd,dd$(),1
html "</TD></TR><TR><TD bgcolor=tan align=right>Notes</TD><TD>"
textarea #notes,notes$,25,3
html "</TD></TR><TR bgcolor=tan><TD colspan=2 ALIGN=CENTER>"
button #inc, "Increment", [incr]
button #rnd, "Random", [rand]
button #ex, "Exit", [exit]
html "</TD></TR></TABLE>"
wait
[incr]
value = val(#val contents$())
value$ = str$(value + 1)
goto [screen]
[rand]
value$ = str$(int(rnd(1) * 10000))
goto [screen]
[exit]
print "Bye"
end

View file

@ -0,0 +1,62 @@
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 2265
ClientLeft = 60
ClientTop = 600
ClientWidth = 2175
LinkTopic = "Form1"
ScaleHeight = 2265
ScaleWidth = 2175
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdRnd
Caption = "Random"
Height = 495
Left = 120
TabIndex = 2
Top = 1680
Width = 1215
End
Begin VB.CommandButton cmdInc
Caption = "Increment"
Height = 495
Left = 120
TabIndex = 1
Top = 1080
Width = 1215
End
Begin VB.TextBox txtValue
Height = 495
Left = 120
TabIndex = 0
Text = "0"
Top = 240
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'-----user-written code begins here; everything above this line is hidden in the IDE-----
Private Sub Form_Load()
Randomize Timer
End Sub
Private Sub cmdRnd_Click()
If MsgBox("Random?", vbYesNo) Then txtValue.Text = Int(Rnd * 11)
End Sub
Private Sub cmdInc_Click()
If Val(txtValue.Text) < 10 Then txtValue.Text = Val(txtValue.Text) + 1
End Sub
Private Sub txtValue_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8, 43, 45, 48 To 57
'backspace, +, -, or number
Case Else
KeyAscii = 0
End Select
End Sub