Forum Replies Created
-
AuthorPosts
-
Another way for initializing an array-of-arrays, provided by Mark himself:
Monkey123456789101112131415161718192021222324252627282930313233#Import "<std>"Using std..Function Main()Global map := New Int[][] (New Int[]( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ),New Int[]( 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 ),New Int[]( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),New Int[]( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),New Int[]( 0, 0, 0, 0, 8, 8, 0, 0, 0, 0 ),New Int[]( 0, 0, 0, 0, 8, 8, 0, 0, 0, 0 ),New Int[]( 0, 0, 0, 8, 8, 8, 8, 0, 0, 0 ),New Int[]( 0, 0, 8, 0, 0, 0, 0, 8, 0, 0 ),New Int[]( 0, 8, 0, 0, 0, 0, 0, 0, 8, 0 ),New Int[]( 8, 0, 0, 0, 0, 0, 0, 0, 0, 8 ) )For Local i := 0 To 9Local out:String = ""For Local j := 0 To 9out += String( map[i][j] ) + " "NextPrint outNextEndGood example for the MX2-CODE-COLLECTION.
@xaron:
Maybe you could use array-of-arrays for this case?Monkey1234567891011121314151617181920212223242526272829303132333435#Import "<std>"Using std..Function Main()Global map := New Int[][10]'Now I'd like to fill that array line by line, something like:map[0] = New Int[]( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 )map[1] = New Int[]( 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 )map[2] = New Int[]( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )map[3] = New Int[]( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )map[4] = New Int[]( 0, 0, 0, 0, 8, 8, 0, 0, 0, 0 )map[5] = New Int[]( 0, 0, 0, 0, 8, 8, 0, 0, 0, 0 )map[6] = New Int[]( 0, 0, 0, 8, 8, 8, 8, 0, 0, 0 )map[7] = New Int[]( 0, 0, 8, 0, 0, 0, 0, 8, 0, 0 )map[8] = New Int[]( 0, 8, 0, 0, 0, 0, 0, 0, 8, 0 )map[9] = New Int[]( 8, 0, 0, 0, 0, 0, 0, 0, 0, 8 )For Local i := 0 Until 10Local out:String = ""For Local j := 0 Until 10out += String( map[i][j] ) + " "NextPrint outNextEnd@xaron
New Int[10,10] is a multi-dimensional 10×10 array.New Int[][10] is an array of arrays, and each array can be different in size:
Monkey12345678910111213141516171819202122#Import "<std>"Using std..Function Main()Local arr:=New Int[][3]arr[0] = New Int[2] ' create new Int-Array with 2 slots (0 and 1)arr[1] = New Int[4] ' create new Int-Array with 4 slots (0 to 3)arr[2] = New Int[6] ' create new Int-Array with 6 slots (0 to 5)arr[0][1] = 2arr[1][3] = 4arr[2][5] = 6Print arr[0][1]Print arr[1][3]Print arr[2][5]EndLike you did with ‘New Byte’ in the other code:
Monkey1buffer := New char_t[1024]You access the address of the buffer using ‘VarPtr buffer[0]’
Monkey123456789101112131415161718192021222324252627282930#Import "<libc>"Namespace APPUsing libcExternFunction fgets:char_t Ptr(chr:char_t Ptr, n:Int, stream:FILE Ptr)PublicFunction GetInput:String(prompt:String)Local buffer:char_t[] = New char_t[1024] ' MEM ADRESS FOR INPUTfputs(prompt, stdout) ' PROMPT THE USERfgets(Varptr buffer[0], 1024, stdin) ' PIPE "stdin" into "bufer"Return String.FromCString(Varptr buffer[0]) ' Return Monkey String from 'Buffer'EndFunction Main()Print "Hi how are you?"'Get C InputLocal answer:String = GetInput("Enter: ")Print "good boy"EndMonkey123456Function GetInput:String(prompt:String)Local buffer:char_t ' MEM ADRESS FOR INPUTfputs(prompt, stdout) ' PROMPT THE USERfgets(Varptr buffer, 1024, stdin) ' PIPE "stdin" into "bufer"Return String.FromCString(Varptr buffer) ' Return Monkey String from 'Buffer'EndYou need to allocate memory for the buffer in the first line.
Just ‘buffer:char_t’ is not a memory buffer of 1024 chars.Did you try to change the current directory to your app directory at start?
Do you just call “wget.exe” or “AppDir\wget.exe” (full path)?> Here’s an example showing that it just doesn’t work.
> https://dl.dropboxusercontent.com/u/2842751/image_test.zipMark should take a look at your example.
Here an ugly test using casting to ‘Void Ptr’:
Monkey12345678910111213141516171819202122232425262728293031323334353637383940#Import "<std>"#Import "<mojo>"Using std..Using mojo..#Import "assets/"Class MyWindow Extends WindowField myImage:ImageMethod New(title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null)Super.New(title,width,height,flags)MyImageLoadingFunc2( Varptr myImage )EndMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()If myImage Thencanvas.DrawImage(myImage,50,50)ElsePrint "Nope, no image"EndifEndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndFunction MyImageLoadingFunc(imagePtr:Void Ptr)Local im:Image Ptr = Cast<Image Ptr>(imagePtr) ' with temporary variable for castingim[0] = Image.Load("asset::test.jpg")EndFunction MyImageLoadingFunc2(imagePtr:Void Ptr)Cast<Image Ptr>(imagePtr)[0] = Image.Load("asset::test.jpg") ' without temporary variableEndWorks, but casting to void ptr is not typesafe.
> I have this working properly. Have anyone the same bug with theme colors?
I noticed the same when switching themes. Only GUI colors are changed,
not the syntax highlighting colors within the editor. I’m also using macOS.Thanks! It’s getting better and better…
EDIT:
How can I move the treeview sidebar to the left side?
And I would like to always show “Source” after start,
not “Project” (I would like to make “Source” the first and default item).@nerobot:
Can you make the completion popup window to always open
_under_ the current line, if possible?See screenshots, the popup opens above the current line
all the time, and sometimes it opens on top of the editor.I think it should always open below the current line
and not get into my way.Attachments:
@nerobot:
Using latest github sources, I get the following error:Monkey12345678Mx2cc version 1.1.03***** Building app '/Users/danilo/Monkey/monkey2/src/ted2go/ted2.monkey2' *****Parsing...Semanting.../Users/danilo/Monkey/monkey2/src/ted2go/actions/editactions.monkey2 [29] : Error : Identifier 'buildAndRun' not found/Users/danilo/Monkey/monkey2/src/ted2go/actions/editactions.monkey2 [30] : Error : Identifier 'buildAndRun' not foundRemoved those two lines and everything builds fine.
EDIT:
Another thing with fonts.
The fonts in “ted2go/assets/fonts/” are not copied into the final executable.
I have “verdana.ttf”, “verdanab.ttf”, “Roboto-Medium.ttf”, “RobotoMono-Medium.ttf” there,
and the final .app has only “DejaVuSans.ttf” and “DejaVuSansMono.ttf” in “ted2_macos.app/Contents/Resources/fonts/”Can’t we just use and choose installed system TTF fonts?
Okay, convinced. Will the 3D module be free or paid (for early supporters)?
There are many situations when line continuation can be useful:
‘+’ or ‘&’ for long string concat
‘And’, ‘Or’, ‘Xor’ in longer If-comparisions
‘|’ etc. when combining many binary flags
‘,’ for many parametersIf all that is a problem, ‘..’ or ‘ _’ may be better.
I think it’s easy to do. If the lexer/scanner detects one of
‘+’ ‘-‘ ‘&’ ‘And’ ‘Or’ ‘Xor’ ‘|’ ‘,’ ‘(‘ ‘[‘
as a token, it sets a bool variable ‘LINE_CONTINUATION_OP = True’.
The next call to the lexer, it removes whitespaces first (space+tabs+comments),
and when it detects an EOL (end-of-line), it is skipped if
LINE_CONTINUATION_OP is True.
For all other tokens, LINE_CONTINUATION_OP is set to False.Using this way it is easy to add another token to the list of
line continuation operators. Just add ‘LINE_CONTINUATION_OP = True’
for this specific token. It’s a lexer/scanner-only thing, the parser
does not notify any of this things.@degac:
In my opinion the price should also be comparable to similar products.
If you give $10/month, that’s already $120 for one year, and $1200 in 10 years.
Similar products are usually $80 to $199, often with a life-time license.
Personally I think $10/month is still okay, but I wouldn’t go over the top
and charge for everything like you suggest (docs for example).
The price we pay has to be in relation to the product and market, somehow.Of course, just my opinion.
-
AuthorPosts

