seed7-users Mailing List for Seed7 (Page 3)
Interpreter and compiler for the Seed7 programming language.
Brought to you by:
thomas_mertes
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
|
Feb
(9) |
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
(4) |
Aug
|
Sep
(4) |
Oct
(4) |
Nov
|
Dec
(1) |
2011 |
Jan
(2) |
Feb
|
Mar
(8) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
(2) |
Aug
(6) |
Sep
(7) |
Oct
(3) |
Nov
(10) |
Dec
(4) |
2013 |
Jan
(2) |
Feb
|
Mar
(2) |
Apr
|
May
(1) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(5) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
|
Mar
|
Apr
(1) |
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(4) |
Nov
(1) |
Dec
(1) |
2015 |
Jan
(2) |
Feb
(2) |
Mar
(2) |
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
2016 |
Jan
|
Feb
(3) |
Mar
(2) |
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(3) |
Dec
(3) |
2021 |
Jan
(2) |
Feb
(6) |
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(12) |
Oct
(4) |
Nov
(17) |
Dec
(3) |
2022 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
(2) |
May
|
Jun
(17) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2023 |
Jan
|
Feb
(1) |
Mar
(4) |
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
(1) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
|
2024 |
Jan
|
Feb
(5) |
Mar
(7) |
Apr
|
May
|
Jun
|
Jul
(4) |
Aug
(12) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2025 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Duke N. <duk...@gm...> - 2022-06-13 19:08:58
|
In your manual, you have the following examples: [code] for number range [] (0, 1, 2, 3, 5, 8, 13, 20, 40, 100) do for innerPlanet range {"Mercury", "Venus", "Earth", "Mars"} do for letter range "the quick brown fox jumps over the lazy dog" do [/code] Is it correct to think of `range' to mean: "to the length of"? for number "to the length of" [] (0, 1, 2, .... 20, 40,100) do -- Duke ** Bottom-posting, text-only is the netiquette way! ** |
From: Duke N. <duk...@gm...> - 2022-06-12 13:44:29
|
On Sun, 12 Jun 2022 11:01:01 +0200 Thomas Mertes <tho...@gm...> wrote: > On Sat, 11 Jun 2022 07:04:00 +0200 Duke Normadin > <dukeof...@gm...> wrote: > > s7 sandbox.sd7 > > SEED7 INTERPRETER Version 5.1.632 Copyright (c) 1990-2022 > > Thomas Mertes *** sandbox.sd7(34):52: Match for {choice ::= > > "" } failed end func; > > -----------^ > > Unfortunately this error message refers to the wrong line (34) > instead of the correct one (7). I will look into this issue. > The error message actually refers to the line > > var char: choice is ""; > > where you try to initialize a char variable with a string literal. > Char and string are different types so initializing a char with > a string is not possible. [snip] Thank you for your reply! and advise! and corrections! and suggestions! All good learning materials. Duke ** Bottom-posting, text-only is the netiquette way! ** |
From: Duke N. <duk...@gm...> - 2022-06-12 13:41:51
|
On Sun, 12 Jun 2022 11:16:02 +0200 Thomas Mertes <tho...@gm...> wrote: > On Tue, 7 Jun 2022 05:07:00 +0200 Duke Normadin <dukeof...@gm...> > wrote: > > Hi .. > > I use a Linux Debian-based distro. > > Does anybody have an emacs seed7-mode file they are willing to > > share. > > I failed to create a seed7-mode.el because of my limited > knowledge of Emacs Lisp and the details of its syntax > highlighting. > > Do you know Emacs Lisp and its syntax highlighting? I know enough Emacs Lisp to hack my .emacs file, but that is all. I believe what is needed is a seed7-mode.el. What /current/ language would you say seed7 most resembles? -- Duke ** Bottom-posting, text-only is the netiquette way! ** |
From: Duke N. <duk...@gm...> - 2022-06-12 13:36:32
|
On Sun, 12 Jun 2022 11:29:23 +0200 Thomas Mertes <tho...@gm...> wrote: > On Tue, 7 Jun 2022 16:59:00 +0200 Duke Normadin <dukeof...@gm...> > wrote: > > I've just put together a syntax file for the nano editor. > > It can/needs improvement(s), but it works just fine as is. > > I can make it available. How? > > Great. If it is a text file (XML, JSON or otherwise non-binary) > you can just send the file(s) content just as part of a mail like: > ---------- begin seed7.nanorc ---------- # Seed7 syntax highlighting for Nano editor # on Debian distros, this file lives in $HOME/.config/nano/ # change the colours to suit your taste. syntax "seed7" "\.sd7" ##[Keywords 1] color brightcyan "\<(begin|case|const|do|downto|else|elsif|end|enum| exp|for|forward|func|false|if|in|include|inout|is|local|new|of|otherwise|param|range|ref|repeat|result|return|sci|struct|syntax|system|then|to|true|until|val|var|when|while) exp|for|forward|func|false|if|in|include|inout|is|local|new|of|otherwise|param|range|ref|repeat|result|return|sci|struct|syntax|system|then|to|true|until|val|var|when|\>" ##[Keywords 2] color brightred "array|biginteger|bigrational|bitset|boolean|char| color|complex|duration|expr|file|float|func|hash|integer|object|proc|program|rational|reference|ref_list| color|complex|duration|expr|file|float|func|hash|integer|object|proc|program|rational|reference|set|string|text|time|type|varfunc|void" ## strings ##color green ""(\\.|[^"])*"" ## Strings, double-quoted color green ""([^"]|(\\"))*"" "%[QW]?\{[^}]*\}" "%[QW]?\([^)]*\)" "% [QW]?<[^>]*>" "%[QW]?\[[^]]*\]" "%[QW]?\$[^$]*\$" "%[QW]?\^[^^]*\^" "%[QW]?![^!]*!" ##[Keywords 3] ## color cyan "\+|-|\>|\<|\^|:|=|:=|<>|<=|>=|><|**|<<|>>|<&|+:=|-:=| ## \*:=|\/:=|\<<:=|>>:=|\&:=|\@:=" ##[Keywords 4] color magenta "\<(and|conv|digits|div|exp|lpad|lpad0|mdiv|mod|mult| not|or|parse|rem|rpad|sci|times|varconv)\>" ##[Keyword 5] color brightblue "read|readln|write|writeln" > ---------- end seed7.nanorc ---------- This nano syntax file is a WIP and my first attempt to get something working. It needs improvement that is certain. :) -- Duke ** Bottom-posting, text-only is the netiquette way! ** |
From: Thomas M. <tho...@gm...> - 2022-06-12 09:29:36
|
On Tue, 7 Jun 2022 16:59:00 +0200 Duke Normadin <dukeof...@gm...> wrote: > I've just put together a syntax file for the nano editor. > It can/needs improvement(s), but it works just fine as is. > I can make it available. How? Great. If it is a text file (XML, JSON or otherwise non-binary) you can just send the file(s) content just as part of a mail like: ---------- begin blah.xxx ---------- # Seed7 syntax highlighting for Nano ... ---------- end blah.xxx ---------- For a binary file you can try an attachment. If you allow me to add your Nano syntax highlighting to the official Seed7 release is will gladly add it. Many thanks in advance for your effort. Regards Thomas |
From: Thomas M. <tho...@gm...> - 2022-06-12 09:16:10
|
On Tue, 7 Jun 2022 05:07:00 +0200 Duke Normadin <dukeof...@gm...> wrote: > Hi .. > I use a Linux Debian-based distro. > Does anybody have an emacs seed7-mode file they are willing to > share. I failed to create a seed7-mode.el because of my limited knowledge of Emacs Lisp and the details of its syntax highlighting. Do you know Emacs Lisp and its syntax highlighting? Regards Thomas |
From: Thomas M. <tho...@gm...> - 2022-06-12 09:01:12
|
On Sat, 11 Jun 2022 07:04:00 +0200 Duke Normadin <dukeof...@gm...> wrote: > s7 sandbox.sd7 > SEED7 INTERPRETER Version 5.1.632 Copyright (c) 1990-2022 Thomas > Mertes *** sandbox.sd7(34):52: Match for {choice ::= "" } failed > end func; > -----------^ Unfortunately this error message refers to the wrong line (34) instead of the correct one (7). I will look into this issue. The error message actually refers to the line var char: choice is ""; where you try to initialize a char variable with a string literal. Char and string are different types so initializing a char with a string is not possible. The error message refers to the ::= operator that is never called explizit. The ::= operator is used only by declaration statements to initialize a variable or constant. To correct this error use var char: choice is ' '; instead. This initializes the char variable choice with the char literal ' '. > *** sandbox.sd7(34):32: Declaration of "choice" failed > end func; > -----------^ This is a follow up error of the previous one. > *** sandbox.sd7(19):52: Match for {choice getc } failed > getc(choice); The function getc has a file a parameter and returns a char. So getc cannot be used with a char parameter (choice). I suggest to use choice := getc(IN); instead. IN refers to the standard input file. > *** sandbox.sd7(34):32: Declaration of "main" failed > end func; > -----------^ This is a follow up error of all previous errors. > The error msgs are not very informative IMHO. I will try to look into that. > You have very detailed language specs, but > very few simple examples of everything possible. Newcomers to Seed7 > have to hut and search and dig for examples at the rosettacode > site. That is /not/ good advocacy! It's too bad that this is the > situation, because you might have a popular and productive language > if there was a comprehensive tutorial to learn it from. Thank you for the hint. I will try to improve the tutorial. Your example uses also 'break' which is not needed in Seed7 case statements. Below is my improved version of your example: ---------- begin sandbox.sd7 ---------- $ include "seed7_05.s7i"; $ include "float.s7i"; const proc: main is func local var char: choice is ' '; var integer: tempF is 0; var float: tempC is 0.0; begin writeln("Temperature Conversion Utitlity"); writeln("-------------------------------"); writeln("a - Fahrenheit TO Celsius"); writeln("b - Celsius TO Fahrenheit"); writeln("q - To exit the program"); writeln("Enter your choice"); choice := getc(IN); case choice of when {'a', 'A'}: writeln("choice is " <& choice); when {'b', 'B'}: writeln("choice is " <& choice); when {'q','Q'}: writeln("Goodye ..."); otherwise: writeln("Bad choice..."); end case; end func; ---------- end sandbox.sd7 ---------- I hope that helps. Regards Thomas |
From: Duke N. <duk...@gm...> - 2022-06-11 05:04:38
|
s7 sandbox.sd7 SEED7 INTERPRETER Version 5.1.632 Copyright (c) 1990-2022 Thomas Mertes *** sandbox.sd7(34):52: Match for {choice ::= "" } failed end func; -----------^ *** sandbox.sd7(34):32: Declaration of "choice" failed end func; -----------^ *** sandbox.sd7(19):52: Match for {choice getc } failed getc(choice); *** sandbox.sd7(34):32: Declaration of "main" failed end func; -----------^ The code is here: https://controlc.com/662efc7b The error msgs are not very informative IMHO. Would you clarify please. I must say that once again I find myself struggling to learn your programming language. You have very detailed language specs, but very few simple examples of everything possible. Newcomers to Seed7 have to hut and search and dig for examples at the rosettacode site. That is /not/ good advocacy! It's too bad that this is the situation, because you might have a popular and productive language if there was a comprehensive tutorial to learn it from. Anyway, if you could set me straight for my current issue, then I might be able to keep on going. TIA .. -- Duke ** Bottom-posting, text-only is the netiquette way! ** |
From: Duke N. <duk...@gm...> - 2022-06-07 17:58:13
|
I've just put together a syntax file for the nano editor. It can/needs improvement(s), but it works just fine as is. I can make it available. How? -- Duke ** Bottom-posting, text-only is the netiquette way! ** |
From: Duke N. <duk...@gm...> - 2022-06-07 03:07:41
|
Hi .. I use a Linux Debian-based distro. Does anybody have an emacs seed7-mode file they are willing to share. I found the vim support, but ... TIA .. -- Duke ** Bottom-posting, text-only is the netiquette way! ** |
From: Thomas M. <tho...@gm...> - 2022-04-12 18:57:25
|
Hi Anders, You wrote in a private mail: > I have a question which in a general way is: How to define a general type in a library > which will be decided later on in the specific application? > To illustrate what I am looking for I have created a test application and a library, ... > The heap-library (heapV9.s7i) defines a heap structure and organises it as a binary tree. > As it is now the heap-value needs to be a string. However I want it to be more dynamic and > defined later on when using the heap-structure in an application. > Until now I have not succeeded to solve it. I have been looking at how arrays can be built > for different datatypes but have not been able to apply it for the heap-library. > Maybe this is not the right way to do it. > So my question is if there is a good way to do this? In your mail you attached the files test19.sd7 and heapV9.s7i. I have ommited these files here. I post my answer also to see...@li... because I think that it is also useful for others. I assume that an abstract data type will probably fit your needs. I have attached the heap-library heapV9x.s7i. This library defines the function heapT which uses baseType as parameter. The heapT function creates the actual structure and defines the functions for it. Like with arrays a second call of heapT with the same type as baseType will refer to the same heapType. This is done with the lines heapType := get_type(getfunc(heapT (attr baseType))); if heapType = void then The then part of the if-statement is executed when there is no previous declaration of heapT with this baseType. The line elmHashT := hash [integer] baseType; defines elmHashT as helping type. The type elmHashT is only used inside of the heapT function. The actual declarations are done inside a global ... end global; construct. This makes sure that the declarations are done at a global level. My solution does not need the type daEnum and the functions lessThan() and init(). ---------- begin heapV9x.s7i ---------- const func type: heapT (in type: baseType) is func result var type: heapType is void; local var type: elmHashT is void; begin heapType := get_type(getfunc(heapT (attr baseType))); if heapType = void then global elmHashT := hash [integer] baseType; heapType := new struct var elmHashT: elmH is elmHashT.EMPTY_HASH; var integer: keyMax is 0; # Max of key to the hash-table var array integer: ptrArr is [0 len 0] times integer.value; # indexes to the element stored in elmH end struct; const func integer: length(in heapType: aHeap) is return length(aHeap.ptrArr); const func baseType: readMin(in heapType: aHeap) is func result var baseType: aResultVal is baseType.value; begin if length(aHeap.ptrArr) > 0 then aResultVal := aHeap.elmH[aHeap.ptrArr[minIdx(aHeap.ptrArr)]]; end if; end func; const proc: swap(inout heapType: aHeap, in integer: id1, in integer: id2) is func local var integer: temp is integer.value; begin temp := aHeap.ptrArr[id1]; aHeap.ptrArr[id1] := aHeap.ptrArr[id2]; aHeap.ptrArr[id2] := temp; end func; const proc: add(inout heapType: aHeap, in baseType: aValue) is func local var integer: idx is integer.value; var integer: idx2 is integer.value; var integer: idh is integer.value; begin incr(aHeap.keyMax); incl(aHeap.elmH,aHeap.keyMax,aValue); aHeap.ptrArr &:= aHeap.keyMax; idx := maxIdx(aHeap.ptrArr); if idx > 0 then idx2 := (idx+1) div 2 - 1; # Has to calculate on pairs {even, odd} not {odd, even} while aHeap.elmH[aHeap.ptrArr[idx]] < aHeap.elmH[aHeap.ptrArr[idx2]] do swap(aHeap,idx,idx2); idx := idx2; idx2 := idx > 0 ? (idx+1) div 2 - 1 : 0; # Has to stop when reaches the root node end while; end if; end func; const func baseType: getFirst(inout heapType: aHeap) is func result var baseType: aResultVal is baseType.value; local var integer: elmPtr is integer.value; var integer: idx is integer.value; var integer: idx1 is integer.value; var integer: idx2 is integer.value; begin if length(aHeap.ptrArr) > 0 then elmPtr := remove(aHeap.ptrArr,minIdx(aHeap.ptrArr)); aResultVal := aHeap.elmH[elmPtr]; excl(aHeap.elmH,elmPtr); if length(aHeap.ptrArr) > 0 then elmPtr := remove(aHeap.ptrArr, maxIdx(aHeap.ptrArr)); insert(aHeap.ptrArr,0,elmPtr); idx := minIdx(aHeap.ptrArr); # 0; idx1 := 1; idx2 := 2; while (idx1 <= maxIdx(aHeap.ptrArr) and aHeap.elmH[aHeap.ptrArr[idx1]] < aHeap.elmH[aHeap.ptrArr[idx]]) or (idx2 <= maxIdx(aHeap.ptrArr) and aHeap.elmH[aHeap.ptrArr[idx2]] < aHeap.elmH[aHeap.ptrArr[idx]]) do if idx2 <= maxIdx(aHeap.ptrArr) and aHeap.elmH[aHeap.ptrArr[idx2]] < aHeap.elmH[aHeap.ptrArr[idx1]] then swap(aHeap,idx,idx2); idx := idx2; else swap(aHeap,idx,idx1); idx := idx1; end if; idx1 := 2*idx+1; idx2 := 2*idx+2; end while; end if; end if; end func; end global; end if; end func; ---------- end heapV9x.s7i ---------- I have also modified the test program test19x.sd7 to use the new parameterized heapT. ---------- begin test19x.s7i ---------- $ include "seed7_05.s7i"; include "time.s7i"; include "array.s7i"; include "heapV9x.s7i"; const integer: MAX is 10000; const type: intHeapType is heapT(integer); const proc: main is func local var intHeapType: aHeap is intHeapType.value; var integer: idx is integer.value; var boolean: correct is TRUE; var array integer: checkArr is 0 times integer.value; var integer: aRVal is integer.value; var integer: heapValue is integer.value; begin writeln("\nAdding " <& MAX <& " values to the heap..."); writeln("Before: " <& time(NOW)); for idx range 1 to MAX do aRVal := rand(1,100); checkArr &:= aRVal; add(aHeap,aRVal); #The value added to the heap needs NOT to be converted to a string end for; writeln("After: " <& time(NOW)); checkArr := sort(checkArr); writeln("\nChecking the heap..."); writeln("Before: " <& time(NOW)); idx := 1; while length(aHeap) > 0 do heapValue := getFirst(aHeap); #The value retrieved from the heap is an integer and needs NOT to be converted correct := correct and idx <= MAX and heapValue = checkArr[idx]; incr(idx); end while; writeln("After: " <& time(NOW)); if correct then writeln("Test result correct!"); else writeln("Test result incorrect!"); end if; end func; ---------- end test19x.s7i ---------- I hope that this is what you searched for. Regards Thomas |
From: Thomas M. <tho...@gm...> - 2022-04-02 22:39:46
|
Hi Anders, You wrote: > I get a raise RANGE_ERROR when running the time-function in seed7 program. > As I remember I did not get this error in the previous versions. > Is this something which has been changed with the new version 2022-03-12? > See the attached testprogram. This is the attached test program: ---------- begin test21.sd7 ---------- $ include "seed7_05.s7i"; include "time.s7i"; const proc: main is func local var time: aTime is time.value; var string: aStr is string.value; begin aStr := str(time(NOW)); writeln(aStr); aTime := time(aStr); writeln(str(aTime)); end func; ---------- end test21.sd7 ---------- Running test21.sd7 leads to: C:\seed7\myprg\Test>s7 test21 SEED7 INTERPRETER Version 5.1.621 Copyright (c) 1990-2021 Thomas Mertes 2022-04-02 06:13:20.211221 UTC+2 (DST) *** Uncaught exception RANGE_ERROR raised with {raise RANGE_ERROR } Stack: in time (in varstring: stri) at /c/seed7/lib/time.s7i(360) in main at test21.sd7(11) C:\seed7\myprg\Test> I can confirm that I also get this RANGE_ERROR and this should not happen. The RANGE_ERROR is triggered because the date string ends with " (DST)". DST means daylight saving time. In "2022-04-02 06:13:20.211221 UTC+2 (DST)" the ending UTC+2 (DST) refers to Middle european summer time. The error is: The function time (string) does not check for " (DST)". Instead it raises RANGE_ERROR. With "2022-04-02 06:13:20.211221 UTC+2" it would work correclty. So the summertime introduced this error. The fix is: I changed time (string) to consider the " (DST)". You can find this fix at GitHub ( https://github.com/ThomasMertes/seed7 ). The change in time.s7i is: end if; end if; end if; + if stri = " (DST)" then + aTime.daylightSavingTime := TRUE; + stri := ""; + end if; end if; - aTime.daylightSavingTime := FALSE; if stri <> "" then raise RANGE_ERROR; end if; I hope this helps. Regards Thomas |
From: Thomas M. <tho...@gm...> - 2022-02-22 18:59:07
|
Hi Zachary, Thank you for the fix of fwd.x11.c. I have already updated Seed7 at GitHub (see: https://github.com/ThomasMertes/seed7 ). The next release will contain this fix also. Btw. fwd_x11.c is only used if linking with the X11 library fails. This is recognized by chkccomp.c. In this case it is assumed that a X11 shared object library is available at run-time. Regards Thomas |
From: Zaakari <Za...@pr...> - 2022-02-01 02:47:08
|
Hey Thomas, Thanks for those new arc() functions! Also--as you'll probably notice soon yourself--there are two typos in the fwd_x11.c file that caused the "make" process to fail. It's just two little things. It was simple enough to fix them for my own build; but I've attached a file containing the error messages from gcc if you want to see them. |
From: Zaakari <Za...@pr...> - 2022-01-06 02:14:41
|
Hey Thomas, Would you be able to add a function similar to arc() (within draw.s7i library) but with the addition of a thickness parameter? Or do the underlying graphics libraries not support this? Points can be expanded by drawing filled circles; and lines can be expanded by drawing filled polygons; but--apart from calculating every pixel--I don't know of a way to "expand" arcs. Zachary |
From: Zaakari <Za...@pr...> - 2021-12-18 14:07:24
|
Ah, clipping, yes that's a better idea. I guess it would take about 10 4K monitors before that number would be insufficient. I guess I can get a little too focused on one method. Thanks for the suggestion, Zachary |
From: Thomas M. <tho...@gm...> - 2021-12-15 13:58:24
|
Hi Zachary, you guessed it. It is a limitation of the underlying X11 function XDrawLines(). XDrawLines() uses an array of XPoint elements. Unfortunately an XPoint is defined as typedef struct { short x, y; } XPoint; Therefore the function genPointList() needs to raise RANGE_ERROR, when a coordinate does not fit into a short. You are magnifying the scene such that coordinates greater than 32767 are computed. Such large values will probably never been drawn as they are beyond the normal size of a window. I suggest you use your own data structure to do the magnification and generate the point list just when it is needed. In this case the values could be limited. You could use 32767 for all values greater than 32767 and -32768 for all values less than -32768. Since this probably far beyond the window borders your magnification probably looks ok. You must also consider the coordinates you use with polyLine(), when the lines are drawn. These coordinates need also to be in the range of a short. Regards Thomas |
From: Zaakari <Za...@pr...> - 2021-12-14 20:46:11
|
Hey Thomas, I ran across what seems to be a bug (or, perhaps, just an oversight) with the "genPointList" function in the "graph.s7i" library. For some reason, when I pass values in that are higher than 32767, then it throws a range error. Are these getting bound to small integers, perhaps? I'm using this function within "fpolyLine" to draw slanted rectangles, and need to be able to pass in large values in order to support magnifying the scene they are drawn in. Is there a way to draw a filled polygon without using "genPointList", or could it be modified to accept the full range of integers? It's probably not needed, but I attached a short script as an example to reproduce the issue. It contains some commented-out sections that show the path I took to get to the error, but the last (uncommented) section shows the issue most plainly. Thanks, Zachary |
From: Cleverson <cl...@di...> - 2021-11-20 18:29:13
|
Hi, I forgot to answer what I know about Linux as you asked earlier. There appears not to be a default solution for sound playing in Linux, at least judging by the solutions they implemented for this Rosetta Code's task, where they use a command line tool instead of an API: http://rosettacode.org/wiki/Play_recorded_sounds Greetings Cleverson Em 20/11/2021 09:03, Cleverson escreveu: > Hi Thomas, thanks for your kind answer. My intention in principle is to > use PlaySound, see: > https://docs.microsoft.com/en-us/windows/win32/multimedia/the-playsound-function > > Usually, it comes defined in a header called mmsystem.h (or mmsystem.pas > in a FreePascal / Delphi installation). > > thanks for pointing me to Seed7's foreign interface; I'll try figuring > it out. > > Greetings,, > Cleverson > > > _______________________________________________ > Seed7-users mailing list > See...@li... > https://lists.sourceforge.net/lists/listinfo/seed7-users |
From: Cleverson <cl...@di...> - 2021-11-20 12:03:53
|
Hi Thomas, thanks for your kind answer. My intention in principle is to use PlaySound, see: https://docs.microsoft.com/en-us/windows/win32/multimedia/the-playsound-function Usually, it comes defined in a header called mmsystem.h (or mmsystem.pas in a FreePascal / Delphi installation). thanks for pointing me to Seed7's foreign interface; I'll try figuring it out. Greetings,, Cleverson |
From: Thomas M. <tho...@gm...> - 2021-11-20 08:09:41
|
Hi Cleverson, with sound you hit an interesting area. As you already found out the standard lib does not implement sound. I planned to do a sound lib, but up to now I did not take the time to implement it. The lunar lander (see: http://seed7.sourceforge.net/scrshots/lander.htm ) has something prepared to send frequencies and durations to some sound system. I have some questions: Which sound API functions from Windows do you want to use? Is there a similar sound API under Linux or other Unix systems? Could a combined Windows/Linux sound API be created from it? Seed7 tries to achieve portability between operating systems. For that reason direct calls from an application program to OS API functions are not desireable. To support portability something needs to balance the differences. In the end driver libraries for Windows and Linux (UNIX, BSD, MacOS) would be needed. That said nothing hinders you to write something for Windows. In the Seed7 manual there is a chapter about the foreign function interface (see: http://seed7.sourceforge.net/manual/ffi.htm ). In the first moment this looks complicated, but is not so complicated as it seems. Having sound for Windows could be a starting point. And it would be great if the same API can be supported from Linux in the future. I suggest using a file named snd_win.c for the Windows sound driver. The Linux/Unix one could use the name snd_unx.c. The common header for both APIs would be in snd_drv.h. Please be patient since I have no idea how a sound API looks today. Greetings Thomas |
From: Cleverson <cl...@di...> - 2021-11-20 02:35:18
|
Hi, I'm new to the language, apreciating it so far. How easy is it to do basic audio playing / stoping, especially under Windows? Since the standard lib appears not to implement this, is it possible to e.g. call OS API functions directly? Greetings, Cleverson |
From: Thomas M. <tho...@gm...> - 2021-11-14 08:51:14
|
Hi Zachary In your example the two occurrences of 'array array string' are considered as two different types. This triggers the error. If you introduce a named type for the two dimensional array the error vanishes: const type: stringArray2D is array array string; const func stringArray2D: test_multiplication (in string: value) is func result var stringArray2D: data is 0 times 0 times ""; begin data := 3 times 2 times value; end func; You are right that this happens with all types of multi-dimensional arrays. Declaring a named type helps in all these situations. I also added an explanation to the FAQ at http://seed7.sourceforge.net/faq.htm#two_dimensional_array . I hope this helps Regards Thomas |
From: Duke N. <sid...@gm...> - 2021-11-13 20:15:25
|
On Sat, 13 Nov 2021 19:36:50 +0100 Thomas Mertes <tho...@gm...> wrote: > Hi Duke, > > In your code are line breaks in strings. But this > was easy to fix. I can reproduce a RANGE_ERROR when I > enter aa in response to the question [snip] Before my first post about my difficulty with the code, I was trying to run the temperature converter program from within the jEdit editor. I just now ran my code from a Linux terminal and it works just fine without any modification. So I must have done something correctly. :) Sorry for all the botherand thanks for your time!! -- Duke |
From: Thomas M. <tho...@gm...> - 2021-11-13 18:37:04
|
Hi Duke, In your code are line breaks in strings. But this was easy to fix. I can reproduce a RANGE_ERROR when I enter aa in response to the question Enter your choice With aa I get the stack trace: *** Uncaught exception RANGE_ERROR raised with {raise RANGE_ERROR } Stack: in raise (ref EXCEPTION: anException) at seed7_05.s7i(323) in (attr type) parse (ref string: stri) at seed7_05.s7i(463) in readln (inout file: inFile, inout char: aVar) at enable_io.s7i(102) in readln (inout char: aVar) at enable_io.s7i(170) in main at tst303.sd7(27) The function readln() (in enable_io.s7i(102)) has read the string "aa" and then tries to convert it into a character and this triggers a RANGE_ERROR (in seed7_05.s7i(463)). This can be avoided by reading single characters from the KEYBOARD. See below for the improved example. A RANGE_ERROR could also be triggered when no number is entered for readln(temp); This situation can be recognized with the function succeeds(readln(temp)) The function succeeds() returns TRUE when no exception occurred. If an exception occurred it is caught and the function returns FALSE. I suggest the following fix: [code] $ include "seed7_05.s7i"; include "float.s7i"; include "console.s7i"; include "editline.s7i"; const func float: fahr2cels (in float: temp) is return 0.5556 * (temp - 32.0); const func float: cels2fahr (in float: temp) is return (temp * 1.8) + 32.0; const proc: main is func local var float: temp is 0.0; var char: choice is ' '; var text: console is STD_NULL; begin OUT := open(CONSOLE); IN := openEditLine(KEYBOARD, OUT); clear(STD_CONSOLE); while choice <> 'q' do writeln("\nTemperature Conversion Utility"); writeln("------------------------------"); writeln("a - Fahrenheit TO Celsius"); writeln("b - Celsius TO Fahrenheit"); writeln("q - To exit the program"); write("Enter your choice "); choice := getc(KEYBOARD); writeln(choice); case choice of when {'a'}: write("Enter a number to convert "); if succeeds(readln(temp)) then writeln("\nYour input was " <& temp <& " degrees Fahrenheit!"); write("That's " <& fahr2cels(temp) <& " degrees Celsius!"); else writeln("\nThis is not a number."); end if; write("\nPress any key to continue .."); readln; clear(STD_CONSOLE); when {'b'}: write("Enter a number to convert "); if succeeds(readln(temp)) then writeln("Your input was " <& temp <& " degrees Fahrenheit!"); write("That's " <& cels2fahr(temp) <& " degrees Celsius!"); else writeln("\nThis is not a number."); end if; writeln("\nPress any key to continue .."); readln; clear(STD_CONSOLE); when {'q'}: writeln("Good bye!"); writeln("\nPress any key to continue .."); readln; otherwise: writeln("Sorry! Invalid choice!"); writeln("\nPress any key to continue .."); readln; clear(STD_CONSOLE); end case; end while; end func; [/code] Regards Thomas |