I have a macro and I can get the pos of a literal string. I want my errors to highlight a subset of that string given a computed offset. How can I construct a new sub position base on the old position?
Thanks!
Follow our progress with https://issues.scala-lang.org/browse/SI-8063 for more information.
Related
Hi, I'm pretty new to gamemaker and I'm trying to set a variable (global.b1) to the first value of "global.level_data". For example, global.b1 will be set to mimic the blue outline of "global.level_data"'s first value, which is 0. Can anyone tell me how to do this?
If I look at it correctly, you want to get the first value of an array
I think this should suffice:
global.level_data = [0,0]
global.b1 = global.level_data[0];
It may look confusing if you're not familiar with how arrays work, but the [0] represents the first value of the array (which happens to be 0 as well). The count of arrays also starts with 0 instead of 1.
For further understanding about arrays, I recommend reading this: https://manual.yoyogames.com/GameMaker_Language/GML_Overview/Arrays.htm
And as a side note: if you're creating new variables, the values in that variable will usually not update it's original form (e.g. changing the value global.b1 will not change the value in global.level_data[0] unless you set that yourself).
If you prefer the latter, then I think you're better off using global.level_data[0] for getting and setting directly
I want to make a program where it will ask the user to enter a function, for example, cos(x) + 2. My problem is that, I do not know the syntax or the code on how to make the entered function become a real function where I can manipulate it, like get the derivative of it, plot it, something like that. Can anyone please teach me on how to do that? Thank you!
To create a "real" function, you can use 2 different syntaxes:
function [x]=myfct(a,b)
x=a+b;
endfunction
or
deff("[x]=myfct(a,b)","x=a+b");
Note: if you have only one return varaible, you can omit the square brackets.
The latter form is more straightforward here, because you only need to ask 2 or 3 strings from the user:
function_statement: the answer should be "x=a+b"
input_varaible_list (separated by comas): the answer should be "a,b"
output_varaible_list (separated by comas): the answer should be "x"
Then put it together in a deff:
deff("["+output_varaible_list+"]=myfct("+input_varaible_list+")",function_statement);
If you fix the output variable name as x, then you don't have to ask for it, and the user have to enter only the right hand side of the function statement (after the =). So it becomes:
deff("[x]=myfct("+input_varaible_list+")","x="+function_statement);
For the derivative see the derivative and numdiff functions in the Scilab help.
My -layout is not as expected:
Why does .getstring create a single cell at the end of the table?
Is this a bug?
Can you fix this via getrow and join?
Thanks for your tips
Getstring-Example# http://www.w3schools.com
It's a known... well, annoyance. (Otherwise known as a bug that will never get fixed.) You either have to trim off the extra delimiters using Left(), or you have to use something other than .GetString. .GetRows is probably the most useful, but note that you can't use Join with it: the latter requires a one-dimensional array, while GetRows always returns a two-dimensional array, even if the recordset only returned one column and/or row.
I'm migrating a small program from VB (an excel-embedded macro that I'm just reading with VB I guess) to R. Sorry if the question is stupid, but I haven't worked with VB before.
I have a set of Dim statements that I think are assigning vectors/matrices:
Dim ff(nmax) As Double
Dim jmatrix(nmax, kmax) As Double
I think this is how I would create it in R:
ff<-as.numeric(0:nmax)
jmatrix<-matrix(nrows=0:nmax,ncols=0:kmax)
But I think I would have to do this every time jmatrix (for example) was used in the code, and I have a suspicion that nmax and kmax are going to be changing or looping a lot. I can do that, but its really convenient how VB just declares them once at the start: can I do this in R? To phrase it another way: I want to assign jmatrix at the start of the code and later on, if nmax and kmax change, I can reference jmatrix without reassigning it with respect to the new values of nmax and kmax. I'm also not sure what the difference between a Single and a Double is, but that's a less important part.
I hope that makes sense, and thanks for any input!
These statements do not assign any value to the objects but rather allocate space and type:
Dim ff(nmax) As Double
Dim jmatrix(nmax, kmax) As Double
The equivalents in R would be:
ff <- vector('numeric', length=nmax) # or ff <- numeric(nmax)
jmatrix <- matrix(numeric(nmax*kmax), nmax, kmax)
There is really no equivalent of "single" in R. There is an "integer"-mode which uses 4 bytes per element and your code 0:nmax would have created a specific integer sequence which is not what those Dim VB statements were doing. Your as.numeric(.) would have then changed the class of that result to the R equivalent of "double".
R's objects may not hold their type if an assignment is made. Matrices need to be all of the same mode. You could assign a character value to a position in jmatrix and it would change the entire matrix to character mode.
I don't know the internals of VB or VBA and the R semantics will allocate space in for an object, but assignment to the object may still require copying the result to a tmp value and then assigning that result to a symbol. This means you may need three similar sized objects in the workspace at the same time before the original object's space and the tmp-space is released.
Lists are dynamic structures in the sense that assigning to a position that doesn't exist will automatically extend the object, but matrices are not so designed.
I don't think this option is available in R, and you have to create a new "object" every time the parameter changes. One idea is to declare jmatrix as function and call it whenever you want to reference.
jmatrix <- function() return(matrix(nrow=nmax, ncol=kmax))
jmatrix()
I am using Robot Framework Selenium using python. I need help with grabbing a certain part of the string, without getting an exterior library. lets say the text says " Your range price for your product is from $0- 400" So i want to be able to get the 400 and paste is somewhere else in the test. The number isnt always 400 sometimes it may be 55 or something different. So i think i would need a GET TEXT Starting from the dollar sign count two spaces and take whatever is left. or i can get the first number and add 10. Like in this example its 0 so i want it to paste 10. Please Let me Know!
"Fetch From Right" should cover that. You just have to identify the stop point, which in your example looks like it would be the hyphen between the two number values.
for example: to extract the last five digits of this string ABC12345 you would want to create a variable to assign the text to.
${number}= Get Text (defined location of text, minus parentheses)
Then use this command to retrieve the remainder of the string after your identified stop point (C).
${desiredNumber}= Fetch From Right ${number} C
This is essentially creating a new variable, which is defined as the extracted values from the original variable after that point.
Hopefully this helps.
You could use the built-in function Evaluate to use the python underlying system:
${my_string} Get Text <your-identifier-here>
${result} Evaluate ${my_string}[${my_string}.rfind('-') + 1:]
Also, please have a look if you can use one of the standard available libraries: http://robotframework.org/robotframework/