Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology
Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered
You are not logged in.
in the code below (I assume) that the vm allocates memory locations for all the variables contained in a Cylinder object whenever one is created....at what point (before the user shuts down the console) does the vm free the memory allocated for the instances of Cylinders?
in the example below, is the memory taken up by the two Cylinders that are created then freed once main() function is finished executing?
struct Cylinder =[
Fradius : F,
Fheight : F,
funreturnheightasintergerasstring: fun[Cylinder] S,
funreturnarea : fun [Cylinder] F,
funreturnvolume: fun[Cylinder] F
]mkCylinder;;
fun returnheight(dcylinder)=
let ftoi dcylinder.Fheight -> height in
itoa height;;
fun return_area_function(dyclinder)=
let dyclinder.Fradius *. PIf-> result in
result;;
fun return_volune_function(dyclinder)=
let return_area_function dyclinder-> area in
area *. dyclinder.Fheight;;
fun initcylinder(radius, height, returnheightfunction, returnareafunction, returnvolumefunction)=
_fooS "initializing cylinder";
mkCylinder [radius height returnheightfunction returnareafunction returnvolumefunction];;
fun copy_this_cylinder(dcylinder)=
initcylinder dcylinder.Fradius dcylinder.Fheight dcylinder.funreturnheightasintergerasstring dcylinder.funreturnarea dcylinder.funreturnvolume;;
fun main()=
_showconsole;
let initcylinder 102.0 19.087 @returnheight @return_area_function @return_volune_function -> dcylinder in
(
_fooS strcatn "the height of the cylinder as a float converted to an interger converted to a string is " :: (returnheight dcylinder) :: nil;
_fooS strcatn "the area taken up by the cylinder is ":: (ftoa (return_area_function dcylinder)):: " square meters."::nil;
_fooS strcatn "the volume taken up by the cylinder is " ::(ftoa (return_volune_function dcylinder)):: " cubic meters"::nil;
let copy_this_cylinder dcylinder-> new_cylinder in
(
_fooS "creating new cylinder and changing radius from 102.0 to 10.5 with copy_this_cylinder (dcylinder) function";
set new_cylinder.Fradius= 10.5;
_fooS strcat "the radius of the copied cylinder is" ftoa new_cylinder.Fradius;
);
);
0;;With strcatn, this is not easy to parse the returned string.
No need to make things more difficult for myself and I'll follow that advice.
let ("John" :: "m" :: "25" :: "New York" :: "0123456789" :: nil) ::
("Harry" :: "m" :: "44" :: "Boston" :: "2365478910" :: nil) ::
("Sally" :: "f" :: "32" :: "Seattle" :: "541239870" :: nil ) ::
nil
-> list inwriting lists this way does make them more readable I'll do that from now on, there's less chance of losing track of the () symbols and nil's.
no but you can use a while on list of lines and then get the line [S r1] content for each lines
to check you can also write it directly in a file.
agreed, and fwiw, you can build a string with strcatn (something I touched on in another thread) and the \n sequence and strextr will interpret the \n as the end of a list of words, so in
fun build2() =
strcatn "harry"::"john"::"joe"::"\n"::"sally"::"jenny"::"mary"::"\n"::"maria"::"julia"::"fredonia"::"\n"::nil;;
fun main()=
_showconsole;
_fooSList (hd (strextr build2));;_fooSList (hd (strextr build2));;will print
harryjohnjoeNILto the console/log
so you can use either strbuild or strcatn to build a string that strextr can turn back into a list of lists of strings, with strcatn being eaiser in my opinion since you don't have to worry about sublists and () symbols
I was trying to figure out strbuild and strextr and how they work together thise weekend, or, rather, trying to remember what I forgot how to figure out. For whoever, including me, on how strbuild and strextr work to build lists of strings into strings and turn strings into lists of lists of strings, helps in handling text, especially if you want to do something meaningful with strings you build and turn them into list objects that you can step through to extrat information.
One thing out I found out (again, perhaps) is that there is no way to write the unmodified return value of strextr to the console/log, since there is no function to write a list of lists of strings to the console/log.
fun build() =
strbuild ("harry"::"john"::"joe"::nil)::("sally"::"jenny"::"mary"::nil)::("maria"::"julia"::"fredonia"::nil)::nil;;
fun main()=
_showconsole;
let strextr build-> llist in
let hd llist -> text in
let hd (tl llist) -> secondline in
(
_fooS strcat "the result of the command strbuild is (\"harry\"::\"john\"::\"joe\"::nil)::(\"sally\"::\"jenny\"::\"mary\"::nil)::(\"maria\"::\"julia\"::\"fredonia\"::nil)::nil; is a string, and this is the string: " build;
_fooS "strextr takes a string of the format above, and whenever it encounters a string like (\"harry\"::\"john\"::\"joe\"::nil), it converts that substring into a list of words. So strextr returns a list of lists, where each list is a list of words such as (\"harry\"::\"john\"::\"joe\"::nil). There is no scol function that displays a list of lists to the console so you have to break up the return value of strextr into parts, each of which is a list of strings, which you can print to the console using _fooSList. So the head of the list returned by strextr is itself a list, which can be written to the console using _fooSList, as below:\n ";
_fooSList text;
_fooS "\n \n you can show the next line, which is the next list in the list of lists, as the head of the tail of the list of lists returned by strextr, as below: \n" ;
_fooSList secondline;
_fooS " \n \n to show the end of the list of lists returned by strext where you have three lines (which is three lists of strings followed by nil), which is the value \"nil\", you have to find the head of the tail of the tail of the tail of the list, which itself is a list of one item, which is always \"nil\" \n when you have a list containing a list of lists, it's easier to do a recursive function to shrink the tail of the list so you are not dealing with tails of tails of tails of tails of tails ad infinitu. Below is the head of the tail of the tail of the tail of list where the list has three lines, followed by the last list, which is just a stub, nil";
_fooSList (hd (tl( tl (tl llist))));
);
0;;
Go arkeon!!!!!
you can can make sprites with bitmaps of use the 3D engine ^^
hmmmm.......perhaps using the web navigator will work as a gui for doing projects with scol programming on an android. web page talks to os3d scene, scene does logic with scol, scene talks to gui elements on web page to display text.
Thx Arkeon. ...so is there a way I can use some of the scol api to make a simple gui app on Android with the apk generator you wrote?
Ayant vécu à New York par les attentats du 11 septembre il y a plein de choses que je pourrais dire, mais tout ce que je peux dire, c'est que je sais ce qu'il doit sentir que de vivre en France dès maintenant.
So all these apis work?
http://redmine.scolring.org/projects/sc … ed/2d.html
For that, it is already done. You can try.
ok, will do with that life example I made.
so how would I begin writing non ui scol apps for android, analogous to printing strings to the console on windows? i.e, what classes/objects/functions can scol access on android?
//this is the pseudo parent of all the classes in this example
struct Animal =[
ihasbackbone: I, //0 no backbone, 1 backbone
idiet: I, //0 for vegetarian, 1 for carnivore, 2 for omnivore
ibiome: I, //0 water, 1 land, 2 air
imulticellular: I,//0 unicellular, 1 colonial like dcoral, 2 multicellular
igender: I,//0 hermaphrodite, 1 female, 2 male
ilegs: I, //0 for none, interger for amount of legs
sname: S //every animal has a name!
]mkAnimal;;
//pseudo subclass of Animal
struct Invertebrate= [
pclassanimal: Animal,//parent type of Invertebrate which inherits all properties and functions
ishelltype: I //0 no shell, 1 outer shell, 2 vestigial inner shell like a squid
]mkInvertebrate;;
//pseudo subclass of Invertebrate
struct Mollusc =[
pclassInvertebrate: Invertebrate,
imollusctype: I //0 for relatively stationary like clam or mussel, 1 for octopid like octopus, squid, or nautilous
]mkMollusc;;
//create an interface that can accept different objects and process them differently, each object must call a function that returns the constructer that allows the object to be referenced by the interface
typedef InterfaceAnimal_Interface =
Animal_interface Animal
|
Invertebrate_interface Invertebrate
|
Mollusc_interface Mollusc
|
Other_animal_interface;;
//allow an Animal type object to be a object that implements(?) the InterfaceAnimal_Interface
fun animal_plug_into_Animal_interface(panimal)=
Animal_interface panimal;;
fun invertebrate_plug_into_Animal_interface(pInvertebrate)=
Invertebrate_interface pInvertebrate;;
fun mollusc_plug_into_Animal_interface(pmollusc)=
Mollusc_interface pmollusc;;
fun invertebrate_dispatcher (pinvertebrate)=
_fooS "printing an invertebrate fields from the InterfaceAnimal_Interface";
_fooS strcat "the name of this invertebrate is " pinvertebrate.pclassanimal.sname;;
fun printanimalinformation(panimalinterfaceobject)=
match panimalinterfaceobject with
(Animal_interface tanimal -> _fooS "this is an animal or some type of animal")
|
//extract Invertebrate object from InterfaceAnimal_Interface and send the resulting Invertbrate to a function...I don't see any practical use for this, but it shows you can plug an Invertebrate into the InterfaceAnimal_Interface and extract an Invertbrate from the InterfaceAnimal_Interface
(Invertebrate_interface tInvertebrate -> invertebrate_dispatcher tInvertebrate)
|
(Mollusc_interface tmollusc -> _fooS "this is an animal and also an invetebrate and also a mollusc or some type of mollusc")
|
(_ -> _fooS "this is not an animal, it's a vegetable or mineral");;
// make an animal and set its properties
fun initAnimal(pbackbone, pdiet, pbiome, pmulticellualr, pgender, plegs, pname)=
let mkAnimal [pbackbone pdiet pbiome pmulticellualr pgender plegs pname]-> lanimal in
(
printanimalinformation (animal_plug_into_Animal_interface lanimal);
lanimal;
);;
// make an Invertebrate and set its properties
fun initInvertebrate(panimal, pshelltype)=
let mkInvertebrate [panimal pshelltype]-> linvertebrate in
(
printanimalinformation (invertebrate_plug_into_Animal_interface linvertebrate);
linvertebrate;
);;
// make an Mollusc and set its properties
fun initMollusc(pinvertebrate, pmollusctype)=
let mkMollusc [pinvertebrate pmollusctype]-> lmollusc in
(
printanimalinformation (mollusc_plug_into_Animal_interface lmollusc);
lmollusc;
);;
//make a new mollusc, we know its name, its type of environment, what it eats, how many legs it has, and its mollusc subtype
//some of the arguments will help construct parent objects, and one of them (mollusc subtype) will determine what kind of mollusc it is
//mollusc name, mollusc biome, mollusc diet, mollusc leg amount, invertebrate parent, mollusc subtype
//this function displays the mollusc's properties, including properties of its parent types, and returns a mollusc type since that's the last statement in the function
//i put p in front of each argument, to stand for "pass" as in passing a variable to the function i put l in front of the objects create, since they are local objects, or temporary objects, so i guess after executing the function all that you are left with is its return value, which can be used in other functions, and i guess if it isn't used in other functions, the return value is destroyed after the function is execute too(?)
fun new_mollusc (pname, pbiome, pdiet, plegs, pinvertebrate, pmollusctype)=
_fooS "\n";
//initAnimal backbone type, diet type, biome type, multiceullartype, gender, amount of legs, and name
let initAnimal 0 pdiet pbiome 2 0 plegs pname -> lanimal in
//initInvertebrate animal parent class, shell type
let initInvertebrate lanimal 1 -> linvertebrate in
//initMollusc, invertebrate parent class, mollusc subtype
let initMollusc linvertebrate pmollusctype -> lmollusc in
(
_fooS "making a mollusc";
_fooS strcat "the mollusc's name is " lmollusc.pclassInvertebrate.pclassanimal.sname;
_fooS strcat "the mollusc's amount of legs is " (itoa lmollusc.pclassInvertebrate.pclassanimal.ilegs);
if (lmollusc.pclassInvertebrate.pclassanimal.idiet == 0) then
(
_fooS "this mollusc is a vegetarian";
)
else if (lmollusc.pclassInvertebrate.pclassanimal.idiet == 1) then
(
_fooS "this mollusc is a carnivore";
)
else
(
_fooS "since this mollusc doesn't eat just plants or just animals, but has to eat something, because that's what animals do, it's an omnivore.";
);
if (lmollusc.imollusctype == 0) then
(
_fooS "the mollusc doesn't swim alot";
)
else
(
_fooS "the mollusc swims all over";
);
if (lmollusc.pclassInvertebrate.pclassanimal.ibiome == 0) then
(
_fooS "this mollusc lives in the water";
)
else
(
_fooS "this mollusc lives on land, or maybe is a new type of mollusc that flies through the air!";
);
lmollusc;
);;
fun main()=
_showconsole;
//make a new mollusc, like a clam or mussel, we know its name, its type of environment, what it eats, how many legs it has, and its mollusc subtype
//mollusc name, mollusc biome, mollusc diet, mollusc leg amount, invertebrate parent, mollusc subtype
new_mollusc "clam" 0 2 0 nil 0;
//this verifies that the function new_mollusc in fact returns a mollusc that we can use
let new_mollusc "nautilus" 0 1 50 nil 1 -> testmollusc in
_fooS strcatn "testing new mollusc function return value"::"this is a mollusc because it has the property named imollusctype and the value of the imollusctype is ":: (itoa testmollusc.imollusctype)::nil;;when I have time, i'll add a typedef to this, and add some function that would "plug in" and object to a typedef tree (a tree that only splits into branches once, I would think)...I've been reading a book on vb.net, which supports classes, inheritance, and polymorphism, so I think I understand that typedef is a bit like an Interface in vb.net although I'm sure that there are differences.
while structs are used all the time, I'm finding it hard to figure out where typedef would be useful in a practical application....maybe a simulation or game where different types have to interact in some way (like big monster versus small robot? or small trilobite versus out of control dump truck?)
I can see from my search through the scol voyager folder on my computer that the term isn't used even once in all of the Partition_LockedApp folder's .pkg files.
[edit]
I added a typedef type named "InterfaceAnimal_Interface" and statements to "plug" each type of animal (animal/invertebrate/mollusk) into the typedef type so a function can be passed various forms of animals and do various things. but I'm still wondering how this can be put to use in games/simulations.
I added a couple of lines at the end of the main function to test that new_mollusc returns a mollusk by referring to one of the mollusc struct's properties, which is imollusctype, which is unique to the mollusc struct.
thanks, yes I'd like to see how that function redefining/changing works.
During the warm months I haven't been coding, but it is no longer warm.
Last year I didn't study Iri's example of making functions as fields of a struct, but after looking over his posts and the mini text editor example in the repository, here is a very simple example. It's a cylinder object, that can figure out the area it takes up and its volume by doing calculations with its own fields.
I used to do this in other projects in javascript, but here is how it works in a very very simple way in scol. In javascript, to call a method of a custom object, you could write somethinglike
customobject.custommethod();struct Cylinder =[
Fradius : F,
Fheight : F,
funreturnheightasintergerasstring: fun[Cylinder] S,
funreturnarea : fun [Cylinder] F,
funreturnvolume: fun[Cylinder] F
]mkCylinder;;
fun returnheight(dcylinder)=
let ftoi dcylinder.Fheight -> height in
itoa height;;
fun return_area_function(dyclinder)=
let dyclinder.Fradius *. PIf-> result in
result;;
fun return_volune_function(dyclinder)=
let return_area_function dyclinder-> area in
area *. dyclinder.Fheight;;
fun initcylinder(radius, height, returnheightfunction, returnareafunction, returnvolumefunction)=
_fooS "initializing cylinder";
mkCylinder [radius height returnheightfunction returnareafunction returnvolumefunction];;
fun copy_this_cylinder(dcylinder)=
initcylinder dcylinder.Fradius dcylinder.Fheight dcylinder.funreturnheightasintergerasstring dcylinder.funreturnarea dcylinder.funreturnvolume;;
fun main()=
_showconsole;
let initcylinder 102.0 19.087 @returnheight @return_area_function @return_volune_function -> dcylinder in
(
_fooS strcatn "the height of the cylinder as a float converted to an interger converted to a string is " :: (returnheight dcylinder) :: nil;
_fooS strcatn "the area taken up by the cylinder is ":: (ftoa (return_area_function dcylinder)):: " square meters."::nil;
_fooS strcatn "the volume taken up by the cylinder is " ::(ftoa (return_volune_function dcylinder)):: " cubic meters"::nil;
let copy_this_cylinder dcylinder-> new_cylinder in
(
_fooS "creating new cylinder and changing radius from 102.0 to 10.5 with copy_this_cylinder (dcylinder) function";
set new_cylinder.Fradius= 10.5;
_fooS strcat "the radius of the copied cylinder is" ftoa new_cylinder.Fradius;
);
);
0;;
Edit....I added a new function that copies a cylinder and returns a new one, something like
var henry = new Cylinder(Robert);in javascript or
dim henry = new Cylinder (Robert)in vb.net/vb/vb script
where Robert is an existing Cylinder and henry is a new cylinder and not just a reference to the original cylinder.
You can provide a hexadecimal, instead of a decimal, or convert the value in new VM in decimal. Or, as you did, set a string argument.
A much belated thanks for your clarification.
done
Thx Arkeon. I figured that would be pretty easy to fo.
Yes unfortunately Chrome and IE have deprecated their plugin system.
OS3D will not be compatible anymore with them and the export feature for web browser will be disable in next releases until we get the time to look at the possibilities on new systems.For now only stand alone export and Android export will be available.
Can you leave the web export in place for 1.9.x? It still works in Windows running Firefox. Perhaps add a warning dialog if the user chooses to export to web page.
hebdemnobad - thanks for the info.
Also I noticed that SCOL is similar to the F# language. F# too (like SCOL) derives from the language OCaml. Now I'm learning functional programming and F#. For me it is very difficult
After that, I'll be back to learn SCOL (and translate textbooks SCOL-OpenSpace3D on Russian language).
Do you know any other scripting/programming languages?
their last commit date is 4 mounths ago
alas
1. they are students who took a break for the summer, or
2. they are students who lost interest in the project,
or
3, a combination of 1 and 2
i just found this, not nearly as advanced, but an open project using ogre
afaik atm the only browser on windows that os3d works on is firefox, i believe the plugin architecture that the vm uses has been deprecated by chrome (and ie for that matter)
From the viewpoint of a self taught programmer, scol is much like javascript except that scol not only communicates with web pages but ogre via os3d, physics with newton, plus almost any input device I can imagine, with support for serial port communication. So it can take your pulse and turn on your coffee maker or robot to make sure you're awake enough for whatever.
We are a very small time for now, we have to focus on big things like mobile devices ^^
Who in the world had such a crazy idea. But seriously mobile is the future of web 3d content and web in general...or maybe it's the future and I still see things as it's still 2003...
Or maybe it still work in firefox ?
yes....hopefully firefox won't shut down the ability of the plugin to operate. while most people these days use mobile devices to go online, it would be good to have the plugin available in one of the browsers for people who want to post complicated/immersive online content
unless that's too much work.
mobile content delivery is king these days, until everyone develops neck problems ![]()
I think I will disable Web export in next releases since the navigator plugins are no more supported and can't be updated for new navigators the same way.
so export will be restricted to .scol export on authoring machine/.exe for windows/.apk for android?