Re: Is there a way to retrieve a value from a value?
In the post with number :
#194439
You mentioned how the string seperator selected the number wrong. You said:
Mid$("12345", 1, 1)
It retrieved 5
(I believe Mid goes form the middle, in this case it was one number after it, and then 1 number after that number.
Which the middle would be 3, and one after it would be 4, and then it goes to 5. I think if there is 2 numbers it chooses the last.
But when I try to get the next column, following what you wrote, I tried this:
Mid$("12345", 2, 1)
It retrieved 0
(It started at 5 , which is 2 numbers from 3, which is middle, and went one more number and chose the last one to output. There wasnt a number after 5, so instead of crashing because of "null", it gives 0.
--------------------------
Well i think Mid$ is grabbing numbers form the middle and rounding the end number selected if the number of items is uneven. There might be a different way to select and splice elements from a string other than this function. It uses similar syntax as described and may be similar to visual basic way of selecting numbers. Remember the first element in anything is always 0, so 0,1 would start at zero and select 1 elements past it.
Re: Is there a way to retrieve a value from a value?
Wha?
EDIT:
To be clear: Mid$'s parameters are the start position, counting from the left (first character is 0), and a count. As per the MMF2 docs, Mid$("Hello",1,3) gives "ell" (skip one character from the left, then get 3).
Re: Is there a way to retrieve a value from a value?
Mid$ returns a string, hence the $ in the expression Mid$. If there were nothing to retun it DOES NOT return "0", it returns "". If it returns "0" and you have no zero in your string then you need to check everything, ebcause "12345" doesn't have a single "0" anywhere. ;)
Re: Is there a way to retrieve a value from a value?
GameDevs: Don't make any conclusion out of what numbers that Mid$ was supposed to return in that previous post. Mid$("12345", 1, 1) was said to return 5, and Mid$("12345", 2, 1) was said to return 0.
...both statements are incorrect. Mid$("12345", 1, 1) returns 2 and Mid$("12345", 2, 1) returns 3.
Then, I of course recommend the expression in my previous post. Don't convert things to strings if the operation can be carried out with numbers.