How to Use a Variable in host[] - omnet++

I want to achieve this:
*.numPairs = ${N=3}
**.host[0..N].udpApp[0].typename = "UdpBasicApp"
But it does not work. However, if I do like this: **.host[0..3].udpApp[0].typename = "UdpBasicApp", then it works properly.
It means that the problem is that the variable N inside host[] (i.e., host[0..N]) does not work.
Can anyone suggest how to fix this issue (i.e., how to make a variable work inside host[])? Many thanks.

One cannot use a variable as an index of module.

Related

Proximity prompt an image label change visible not working

I'm trying to make it so that when you use a proximity prompt an image label becomes visible but it's not working, how do I fix this?
local proximity = workspace.Cardpack.ProximityPrompt
local proximityPromptService = game.GetService("ProximityPromptService")
proximity.Triggered:Connect(function()
_G.visible = not _G.visible game.Workspace.Inventory.Frame.X1.Visble = _G.visible
end)
You don't really need to use _G for this. Instead, we can directly declare it to the X1.
local prompt = workspace.Cardpack.ProximityPrompt
local x1 = workspace.Inventory.Frame.X1
prompt.Triggered:Connect(function()
x1.Visible = not x1.Visible
end)
_G.visible = not _G.visible game.Workspace.Inventory.Frame.X1.Visble = _G.visible
This is where your script goes entirely wrong. This is not LUA syntax and is not how programming works. This is actually what you are currently trying to do.
local value = true = false;
Really what you should be doing is creating a reference to the ImageLabel you are trying to set. Then change it's properties. Setting a variable in the global enviroment won't change the ImageLabel's properties.
local ProximityPromptService = game.GetService("ProximityPromptService");
local ImageLabel = workspace.Inventory.Frame.X1;
local Proximity = workspace.Cardpack.ProximityPrompt;
proximity.Triggered:Connect(function()
ImageLabel.Visible = true;
end)
This seems to be a simple issue which can be solved with a simple solution (granted you know what you're doing). Now here's some things to note:
You don't need to use the ;'s you see on almost every line people make. It's not something mandatory and shouldn't be. Though it's good for when you want to have less lines (if it's your preference).
You wouldn't want to have 2 ='s on the same line as it's not the correct syntax (as #sl0th has stated), you cannot attempt such a task as it wouldn't even work. You want it to not just change it back to false anyways.
As you code this, I don't believe you fully understand how it works, and to make the code you first of all have to understand COMPLETELY or rather fluently how it works. So let's start off with that!
How do we do this? Let's see:
-- Perhaps put the script INSIDE of the Cardpack, and then do it from here.
-- Also, I'm not sure why you've put an "inventory.Frame" here, if it's a screengui then it should go in StarterGui, however if it's a billboardgui then please ignore me.
local Cardpack = script.Parent -- I've added it inside the cardpack as said.
local Prompt = Cardpack.ProximityPrompt
local Label = workspace.Inventory.Frame.X1 -- using the original directory as I don't know how your explorer looks.
local CanBeVisible = false -- if you want to toggle it.
Prompt.Triggered:Connect(function() -- make sure to look up on devforum about this.
if not CanbeVisible then -- "not CanBeVisible" is equivalent to "CanBeVisible==false".
CanBeVisible = true
Label.Visible = true
else -- if it's true and not false:
CanBeVisible = false
Label.Visible = false
end
end)
This is a more..."Acceptable" way of coding. People have their preferences, but this is generally how I'd do it based on how you did it. IF you don't understand much I'm always here to help, of course! :D
FINAL NOTES:
local A,B = "A", "B" -- you can assign multiple variables on a single line!
A,B = "B", "A" -- and you can also change more than one on the same line too.
local A = "A";print(A) -- that's how ; is used if you want to do more than one thing on the same line (but not done at the the same time on the same line!). ; Seperates the code without needing to add spaces, though adding/casting variables you should stick to using the comma(s) to separate them assigning new values and whatnot.
Also, you don't even need that ProximityPromptService variable as you never even use it! And you can't just do game.GetService(..), you IDEALLY do it as game:GetService(..).
I hope this helped you and if it did, mark this as the answer! Though this is my first time trying to help people I tried my best lol.

How to use dynamic variable in smarty template function

I need to use the variable inside the popup tag from Smarty.
I can't declare the var on the server because it's dynamic (originating from a loop).
I tried all the different approaches with the assign tag like
{assign var=title value="$some_loop_var - sitename!"}
or
{assign var="myfield" value=$some_loop_var + "btn_licencee_select"}
Always the printed variable is empty.
Any ideas what I might be doing wrong?
The solution was quite trivial in the end:
If you use a variable inside a Smarty function you need to "escape" it with backticks:
{popup text="`$some_loop_var`_static_part" }
Hope this helps anybody else as well. Took me hours to figure this out...

Sass/Scss - How to get partial variables as a list?

I would like to loop over all the variables in a single partial, but I can't find away to automate this.
The example:
I have a partial named _colors.scss, it only contains colour variables.
$facebook: #305897;
$twitter: #31aae1;
$google: #da4936;
$pinterest: #c9151a;
These are already used across the site so I can't reformat them as a list.
I would like to do something like, foreach var in _colors return mixin.
But I can't find away to access them without calling each individually...
I am sure I am missing something obvious, and would appreciate someone pointing it out :)
There is no shortcut for this. You'll have to create a list out of them yourself.
$facebook: #305897;
$twitter: #31aae1;
$google: #da4936;
$pinterest: #c9151a;
$social: $facebook, $twitter, $google, $pinterest;

load a variable in matlab

I want to load variables in a loop with different imagenames.
for i=1:length(imagefile)
name=imagefile{i};
% name=image01% load name
end
it looks variable (name) and not (image01), how should I do it
regards,
Not sure exactly what your variable is. An array of strings?
imaefgile = ["image01", "image02"]
for i=1:length(imaefgile)
load(imaefgile(i))
end
P.S. you may also need something like:
load(strcat("Folder/", imaefgile(i), ".mat"))
to concatenate the filename appropriately.

Descendent-or-self in InfoPath

I want to use XPath code in an InfoPath form to sum the data in field12 when field11 is equal to IT. I tried using the following code, but it doesn't work.
number(sum(/descendant-or-self::node()/my:group12[my:field11 = "IT;"]/my:field12))
I suspect this has to do with the multilayering of groups, as shown below. Does anyone know the code that would allow me to get to the data in group12? Thanks in advance for your help.
myfields>group9>group10>group11>group12>field11 field12
Genipro
Looks like:
number(sum(/descendant-or-self::my:group12[my:field11 = 'IT;']/my:field12))
could be right.
decendant-or-self should not be necissary in this case (unless you need the expression to work even if group12 is moved).
This should work fine:
sum(/my:myfields/my:group9/my:group10/my:group11/my:group12[contains(my:field11,'IT')]/my:field12)
It doesn't matter if any of the other groups are repeating either. All group12's will be checked.

Resources