Float[]
Monkey Forums/Monkey Programming/Float[]
| ||
Local Dada:Float[] How do I add to the Float List another Number Lets Say Dada=[45.0,23.0] Now I want to add another number to the list how can I do that? I want Dada to be Dada[45.0,23.0,45.2] Cheers |
| ||
I would use a list or stack for dynamic arrays. |
| ||
I dont know how to use Stack nor Dynamic Arrays |
| ||
I will give you an example later. Currently I'm not at home... |
| ||
:) ok tanx meanwhile... trail and error... |
| ||
...or...Local dada:Float[] = [45.0, 23.0] dada = dada.Resize( dada.Length()+1 ) dada[dada.Length()-1] = 45.2 For Local i:= 0 To dada.Length()-1 Print dada[i] Next ...or.... Local dada:FloatList = New FloatList ''or FloatStack dada.AddLast(45.0) ''stack uses Push() dada.AddLast(23.0) ''..etc.. dada.AddLast(45.2) For Local i:= EachIn dada Print i Next |
| ||
Greate help thanks adam thats all i need a simple code example saves 1000 tutorials. but why does the floatlist doesnt work on polydraw? I mean Example: Local dada:FloatList dada.AddLast(45.0) dada.AddLast(23.0) DrawPoly(dada) gives an error "Unable to find overload for DrawPoly(FloatList)" |
| ||
Im making an online Help for monkey so everything im learning will be added to the Guide. The Guide will be In a CHM file Style. And will be with code examples and will cover Box2D, and anything that I will decide. Also if some people would like to edit it in the future I will give them access to improve its level. Another quastion.. Example: Function Test(Xpos=0,Dada:Float[]=0) How can i make that the Dada in the function can be skiped like you do when you put 0 on XPos in case i dont want to enter Data |
| ||
You should look through the Monkey documentation for built-in functionality. DrawPoly can't take a list, but it can take an array. If it's unable to find an overload for DrawPoly, that means it has no way to handle the input. So a quick look around the documentation would have found you the answer very quickly. DrawPoly(dada.ToArray()) For the other example, I don't know if the documentation clearly states it, but it's surely implied. Here's the minor fix to give an array a default value. Function Test( xPos = 0, data:Float[] = [] ) |
| ||
Tnx. Great Help! Simple. and to the point. Another interesting quastion I always wondred.. When you use a function can you tell the give the function a sign that tells it to use the default value and skip to the next Entry. Example: Function Dada(Xpos=34,YPos=23) code... End Function Dada([SkipXPos],45) I will also look into the docs tnx |
| ||
Im writing.. Class Element field LFloat:Float[] End Class NewE:Element=New Element NewE.LFloat.Resize(2) Print NewE.LFloat.Length --> brings answer 0 any idea why |
| ||
hardcoal, is it going to be like a wiki? That would be most helpful, as long as it has good search functionality. |
| ||
Im using a Help Maker software with its familiar options like Content,Index,Search,Favorits Always will be improved.. with some nice help of the community Thats the plan for now |
| ||
Looks like your problem has been solved! :) |
| ||
Not really Xaron im working all day trying to make A drawpoly function. yet no success. look at this code Import mojo Global Tata:Float[] Function Main() New TestLoop End Function Class TestLoop Extends App Method OnCreate() SetUpdateRate(60) Tata.Resize(3) Print Tata.Length End Method Method OnRender() Cls End Method End Class Why when I Print I get Result Zero and not 3 |
| ||
Because your code is wrong.Tata = Tata.Resize(3) |
| ||
uhhm I was counting on that fact that my code was wrong. other wise it would be working. thanks for the solution |