The Daily Click ::. Forums ::. Klik Coding Help ::. Adding numbers together
 

Post Reply  Post Oekaki 
 

Posted By Message

eski



Registered
  20/09/2009
Points
  39
12th January, 2010 at 00:48:13 -

Hey there
(go to the bottom for the express description on the prob)

I'm trying to make a simple nonogram game and well i'm having some problems regarding the number system on the sides. If you are not familiar with the type of game you can see it here : http://en.wikipedia.org/wiki/Picross

The problem is adding the numbers together.
For example if the blocks are "0 0 1 1 0 1 0 1 1 1" it should read out "2 1 3".
I'm using a array object to manage the x,y and i have variable on every brick that states where it is (x.y), it also has a variable that states if its selected or not.

So basicly i'm asking for a help on what method i should use to get it to work.
I am totally going nuts on trying random methods out of my head.


************

I have a textbox that says "0 0 1 1 0 1 0 1 1 1" and i want another textbox to calculate from that another string that says "2 1 3"

************


I would appreciate any comments on this matter.
Thanks

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
12th January, 2010 at 01:56:13 -

I think this should work as a solution to the "express" version of your problem, although I don't have MMF on this computer, so I can't check it.


+ whenever...
-> start Fastloop "Check", Len( String_In )+1 times

+ on Fastloop "Check"
+ Mid$( String_In, LoopIndex("Check"), 1) = 1
-> set Flag_0 to ON
-> add 1 to Counter

+ on Fastloop "Check"
+ Mid$( String_In, LoopIndex("Check"), 1) = 0
+ Flag_0 is ON
-> set String_Out to String_Out + " " + Str$( Counter )
-> set Counter to 0
-> set Flag_0 to OFF


However, it seems like extra work generating a string from the array, and then another string from that - you could do basically the same thing without the intermediate string. I don't have time to work it out now though

Edited by Sketchy

 
n/a

eski



Registered
  20/09/2009
Points
  39
13th January, 2010 at 03:03:38 -

Hmmm.. ok
I dont seem to get it to work right...

If for example i have "1 1 0 1 1 0 0" i get "2 2" but if the ending has a 1 then it doesnt work.
"1 1 0 1 1 0 1 1" gives me "2 2".


 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
13th January, 2010 at 12:25:11 -

Sorry - I can see why that would be.

Try replacing this:
+ Mid$( String_In, LoopIndex("Check"), 1) = 0

...with this:
+ Mid$( String_In, LoopIndex("Check"), 1) <> 1


I'm was thinking that retrieving the 11th character of a 10 character long string would return "0", but of course it will return "".

Edited by Sketchy

 
n/a

eski



Registered
  20/09/2009
Points
  39
13th January, 2010 at 22:50:14 -

thats the stuff..
now its starting to look right..

thanks alot for the help..

btw.. where can i find all the string expressions ?

 
n/a

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
13th January, 2010 at 23:46:05 -

Under Special[the computer icon]->Strings

But there are shortcut buttons in the expression editor for some of them.

They're labelled; Left$, Mid$, Right$ Len and Str$

Edited by Spitznagl

 
...

eski



Registered
  20/09/2009
Points
  39
14th January, 2010 at 00:41:16 -

hey fellow cabinetmaker

yah, meant how they are used.. and so on..
i will try google it when i'm home...

 
n/a

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
14th January, 2010 at 11:28:58 -

From the MMF2 help file:

The Special Object - Expressions

Strings
Extract left sub-string extracts a sub-string from the given string, starting on the left. Example, LEFT$("Hello", 3) will return "Hel".
Extract right sub-string extracts a sub-string from the given string, starting on the right. Example, RIGHT$("Hello", 3) will return "llo".
Extract middle sub-string extracts a sub string starting at a given position. Example, MID$("Hello", 1, 3) will return "ell".
Length of string returns the number of characters in the given string. Example, LEN("Hello") returns 5
New Line returns a string with new line control characters. The text after these control characters is displayed on the next screen line. Example, "Line 1" + NewLine$ + "Line 2".
Convert String to Lower case returns a string with lowercase characters.
Convert String to Upper case returns a string with uppercase characters.
Find String in String returns the 0-based index of a sub-string in the string. Parameters = string to look into, sub-string to look for and index of the first character to start the search from. Returns -1 if the sub-string is not found in the string.
Find String in String backward returns the 0-based index of a sub-string in the string, from the end of the string. Parameters = string to look into, sub-string to look for and index of the last character to start the search from. Returns -1 if the sub-string is not found in the string.


 
...
   

Post Reply



 



Advertisement

Worth A Click