How to set up conditional breakpoints in spyder? - conditional-breakpoint

it was supposed to be incredibly simple to find answer in open internet but apparently not. How do you set conditional breakpoints in spyder (anaconda)?
for example here is a fraction of the code:
if elem.name == "p":
for b_elem in elem.select('b'):
if not re_date.match(b_elem.text):
speaker = b_elem.text.strip(':')
I want to set up a conditional breakpoint when speaker equals to 'Foreign National Offenders (Exclusion from the UK) Bill'
i tried to set the red dot next to the speaker, right click and edit conditional breakpoint like this: speaker == 'Foreign National Offenders (Exclusion from the UK) Bill'
but the code does not stop at this breakpoint. I wonder why. Does anyone know how to set it up properly?
thank you

The debugger stops at the row where you put the breakpoint before evaluating the row.
So, to have the debug stop based on the value of variable "speaker", you should insert the conditional breakpoint on a row below the one where "speaker" is defined.

Related

Setting up multiple schedules for a ResourcePool

I am doing a simulation of a production line, which is built through Excel.
Now there is one, which needs free setting of worker shifts for each machine, three shifts in total.
My idea is to create three different Schedules, representing each of the three shifts, and then in the ResourcePool, use the If statement to set up the use of each shift. As shown in the picture enter image description here
But it didn't work. If it is possable, Could you please tell me if there is something wrong with the Java statement or the idea is wrong.
If possible, could you please tell me how to set multiple schedules in ResourcePool?
Additions to the question:
The model is to do the evaluation of the production system and the shift of the workers is an important evaluation parameter. What I want to do is to enter the shift of the workers directly in the Excel sheet and ResourcePool recognizes and uses the corresponding Schedule.
I tried to generate the corresponding Schedule by code, but the Schedule of Resourcepool cannot be set dynamically. So I would like to try to manually input multiple Schedules into the model and then set the corresponding Schedule in ResourcePool by If statement like the image.
Thanks in advance
The first thing you need to know is that the location where you placed the code is a static parameter, thus it is only evaluated once, when the object is created and not checked continuously.
This is indicated by the little popup when you hover over the button that change the entry field from code to value
If it was dynamic it would state Dynamic Value instead of Static Value
Secondly, inside that field you must use a ternary operator, not an if statement, so that the result of the formula is a scheduled object, else you will get a "misplaced construct(s)" error
If you changed the code to
v_Shift == "Shift1" ?
s_Shift1 : v_Shift == "Shift2" ? s_Shift2 : s_Shift3
It will work BUT:
It will only be evaluated when the object is created and not again
Rather not use == on Strings, always use .equals(), on Strings it might work, and sometimes it might not. You can do some research as to why ;-)
Solution: You will have to use a function to change the schedule of the resource pool. Call this function whenever the v_Shift variable changes

How to execute if there's a certain block within a radius

I'm trying to figure out how to execute (for example /say hi) when there's Yellow Terracotta in a certain radius or field, however I can't figure out how to do it.
Anyone knows?
Using Minecraft 1.16,
"Execute" command has several syntax options. You can use the form "execute if block run "
Using the proper block name, we can get:
execute if block 1015 63 989 minecraft:yellow_glazed_terracotta run say hi
This targets a specific position.
I am a little less clear on how to achieve specifically what you are asking, but here are my thoughts:
The syntax provides for another form "execute if blocks..." This form allows you to select a range by corners, but it must be compared against a third selection of the exact same size (only the corner can be specified). I think the regions must be exactly the same, and may not allow for random placement of the block anywhere within the region.
Another way might be using different execute if commands instead to select an entity, and test where the entity is standing.
If you put a button on a command block and set it to:
execute at #p if block ~ ~-1 ~ minecraft:yellow_glazed_terracotta run say hi
When the player hits the button on the command block (obviously they must be within range of the button to press it) it shall check if the block -1 under the #p is "yellow_glazed_terracotta", and it will run say hi.
#p can be modified with [distance=..3] which means the player targeted by the command block must be within 3 blocks of the command block:
execute at #p[distance=..3] if block ~ ~-1 ~ minecraft:yellow_glazed_terracotta run say hi
So, this is sort of creating that range that you were looking for.
Some sources use "execute as #a at #s..." as a way to target any player when they step on a certain block anywhere at anytime. It may be possible to modify this into a distance as well, but it seems that the player will need to stand at a specific relative position to the terracotta.
If I find a better way to achieve this, I'll follow up.
The subreddit r/MinecraftCommands has a decent community that messes with Minecraft commands and command blocks. They may have further insight.
If I find a better way to achieve this, I'll follow up.
Edit- The only other thing I can think at this point is to take the first command I suggested and repeat it for every single coordinate in an area. If a terracotta block is any of those spaces, it will run the say hi command.
If you place all of these command lines into a function file you can call for the function when the command block is activated.

How do you handle game battle combos? - Scratch 3.0

I'm new to programming, and I was wondering how you are able to handle consecutive, timed key presses in order for the character to do something different. For example, in games like 'Super Smash Bros.' you press one button for a character to punch, and if you press it again, they will do their second punch; pressing it once more will result in a kick. How am I able to program this in Scratch 3.0 (preferrably, but an explanation in another programming language might help)?
By the way, if this helps, I am using a 'state' variable in order to handle other animations such as running; I want the character to be able to animate when the timed key presses occur.
Makey makey (in the extensions) does something similar to that, but if you wanted to make your own from scratch (no pun intended) you could do something like this example that I made: https://scratch.mit.edu/projects/382244376/
As stated earlier, makey makey is the only option...
I know, they only have a few selected options
BUT!
try this:
You usually use
when (up right down left v) pressed:
// Do something
Why don't you use
when (join(up up right right left left up down)()) pressed:
// Do Something
Yes, its the join()() block. Fill up the first blank with the combos you want, separated by a space, and leave the 2nd one empty. Drag it into the selectable part of the Makey Makey hat block, and there you go!

How to print chained variables using GDB console?

How to print C type variables at GDB console in xcode4? I'm able to print variables using p var, also able to print variables like p myObj.property but unable to print variables that that are on 3rd level depth. For example using p objName.pointerToOtherObject.someProperty does not work. The GDB dislays "There is no member named someProperty." message but it is there for surely. I'm using the 4.02 version of xcode4 but still it sucks when it comes to displaying properties, variables and etc from debug area. I mean it is unable to show the content or arrays and dictionaries, also, sometimes, it is not displaying the values of vars when I move the mouse over that var, in that case I need to click and move the mouse somewhere else and then move the mouse over again, then it works. Maybe I'm missing some hints but those small problems sometimes annoys me :) For object printing I' using po.
The solution would be to use method messaging syntax instead of property syntax:
p [[SomeObj pointerToOtherObject] someProperty]

Obj-C keeping memory addresses the same on next debug

I'm not sure if there is a name for this technique, but I remember doing something like this a long time ago in C++. I would like to breakpoint and observe a specific object of which there are hundreds in my program. It would be nice if you can tell the compiler to use a reserved space of memory so that I can run once, pull out a memory address, then run again with the guaruntee of having the objects allocated to the same address in memory so that I can see what happens to this specific object the next time around.
At the moment I am just assigning a 'debug id' which gets incremented with each allocation but thought there might be a cleaner way of doing it. I'm sure I've done this before with Vis Studio / C++...
You can set a conditional breakpoint in Xcode so that it will only break into the debugger if a certain condition is satisfied.
To do this, set the breakpoint normally and then right-click on it and select Edit Breakpoint.
Locate the breakpoint in the Breakpoints window and double click the "Condition" column. You can then enter an expression, something like:
(BOOL)[[yourObject name] isEqualToString:#"foo"]
This will break only when the name property of yourObject is foo.
Note that you need to cast the result of the expression to a boolean, otherwise gdb doesn't know how to deal with the result of the expression. You also can't use dot notation syntax, you must use the full square bracket syntax.