Make repeat statement support return, break and continue
This commit is contained in:
parent
e561b4eb21
commit
1267a8ed3b
6
NEWS.md
6
NEWS.md
|
@ -1,5 +1,11 @@
|
|||
# Genoa Banner Creator project news
|
||||
|
||||
## [0.5 alpha] - unreleased
|
||||
|
||||
### Changed
|
||||
|
||||
* The repeat statement now supports return, break and continue.
|
||||
|
||||
## [0.4 alpha] - 2023-09-14
|
||||
|
||||
### Added
|
||||
|
|
|
@ -6,7 +6,7 @@ Rationale: I make vector art by hand (see the Pocket Guide to Writing SVG, by Jo
|
|||
|
||||
## Availability
|
||||
|
||||
As of September 2023, Genoa is at a very early alpha stage: incomplete, undocumented and probably buggy. Use at your own risk. System requirements:
|
||||
As of September 2023, Genoa is at a very early alpha stage: incomplete, poorly documented and probably buggy. Use at your own risk. System requirements:
|
||||
|
||||
- to run from source, Tcl/Tk 8.6 with tklib
|
||||
- screen resolution:
|
||||
|
@ -15,7 +15,7 @@ As of September 2023, Genoa is at a very early alpha stage: incomplete, undocume
|
|||
|
||||
## Usage
|
||||
|
||||
Genoa is powered by a little language based on Tcl. Right now it can generate its own promotional banner, like this:
|
||||
Genoa is powered by a little language based on Tcl. For example its own promotional banner is defined like this:
|
||||
|
||||
```tcl
|
||||
# The viewport declaration can be anywhere.
|
||||
|
@ -39,7 +39,7 @@ color darkblue; circles 400 400
|
|||
|
||||
font "Noto Sans"; size 48
|
||||
color white; set j 0
|
||||
foreach i {GENERATE ORIGINAL ART} {
|
||||
foreach i "GENERATE ORIGINAL ART" {
|
||||
incr j 64
|
||||
text 225 [+ 225 $j] $i
|
||||
}
|
||||
|
|
15
genoa.tcl
15
genoa.tcl
|
@ -54,7 +54,20 @@ interp create -safe runner
|
|||
runner eval {
|
||||
proc repeat {times code} {
|
||||
for {set i 0} {$i < $times} {incr i} {
|
||||
uplevel 1 $code
|
||||
set ret [catch {uplevel 1 $code} message]
|
||||
switch $ret {
|
||||
0 {}
|
||||
1 {
|
||||
return -code error \
|
||||
-errorinfo $::errorInfo \
|
||||
-errorcode $::errorCode \
|
||||
$message
|
||||
}
|
||||
2 { return -code return $message }
|
||||
3 { break }
|
||||
4 {}
|
||||
default { return -code $code $message }
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace path {::tcl::mathop ::tcl::mathfunc}
|
||||
|
|
Loading…
Reference in New Issue