Roblox Studio: "Argument 1 missing or nil" - roblox

I was testing out my script that finds the saved data. It gave me an error message saying "Argument 1 missing or nil".
Here's the code:
local DataStoreService = game:GetService("DataStoreService") -- makes the variable for the data store service
local DataStore = DataStoreService:GetDataStore("Data") -- makes the variable for the "Data" data store
local GlobalShutdowns = DataStore:GetAsync(GlobalShutdownsData) -- finds the "GlobalShutdownsData" data from the data store service
Please help me!

You forgot to add quotes when calling GetAsync. This makes Luau believe that GlobalShutdownsData is a variable. GlobalShutdownsData is not defined (there is no variable named GlobalShutdownsData), therefore, the value is nil. Argument 1 of GetAsync is nil.
local DataStoreService = game:GetService("DataStoreService") -- makes the variable for the data store service
local DataStore = DataStoreService:GetDataStore("Data") -- makes the variable for the "Data" data store
--fix below
local GlobalShutdowns = DataStore:GetAsync("GlobalShutdownsData") -- finds the "GlobalShutdownsData" data from the data store service

Related

kdb - passing in a symbol as parameter for variable name

I've been trying to pass in a symbol from a process outside KDB and am wishing to use this symbol to create a variable where we then load a specific file in case it doesn't exist.
//create some sample data and write to disk
.data.area52.varName1: ([] name:`billy`allen`terry; val:90 100 200);
.data.area52.varName2: 10 #200;
.data.area53.varName1: 9 #100;
.data.area53.varName2: ([] name:`joe`jim`bob; val:10 20 30);
.data.area53.varName3: `random;
`:area52 set .data.area52;
`:area53 set .data.area52;
I am trying to pass in the parameter for reference area52for example which will test a conditional if it exists (do nothing, else) then create the variable loading viaget `:area52
First, I wrote a conditional below which seems to check (however trhe `.areaXX isn't parametrized yet.
// fresh instance of KDB
.data.area52: $[`area52 in key `.data; .data.area52; get `:area52
And then stumbled onto the link here kdb+: use string as variable name
Which gets me most of the way there.
Is there a way to parameterize the beginning of the lambda below passing in some combination of `.area52 ? Much of this variable can be assembled / edited outside KDB and only passing in the
for an example, we can have several hundred `.areaXX that we could pass into KDB as data is changed and refreshed.
{.data.area52:()!(); #[`.data; `area52;:; (get `:area52)]} [];
To safeguard against the situation where the namespace .data doesn't exist you could use the following lambda which takes parameter area52 as an argument.
q){(` sv ``data,x) set ()!(); #[`.data; x; :; get hsym x]}`area52
`.data
Tying it back to the original problem, this lambda will create the variable if it does not exist by reading from the file of the same name:
/ .data does not exist yet
q).data
'.data
[0] .data
^
/ create variable if necessary
q){if[not x in key `.data; (` sv ``data,x)set get hsym x]}`area52
/ check .data
q).data
| ::
area52| ``varName1`varName2!(::;+`name`val!(`billy`allen`terry;90 100 200);20..

Azure Data Factory - Capture error details of a dataflow activity -> Store into a variable -> Assign this variable to a dataflow parameter

I have a data flow and my requirement is to capture the error details into a variable when it fails and assign this variable to a parameter in the next data flow. I tried to achieve this until the second stage(With help) as below, but I'm unable to get this variable assigned to a parameter in the next data flow. The error I get is - Expression cannot be parsed
What do I do later?
This parameter is assigned to a column in the data flow and I use this column to update the table in the dedicated pool with the relevant error message.
I tried to reproduce the same in my environment and I got the same error
The above scenario fails, because dataflow fails to parse ' ' and / in your error message.
To resolve above error,please follow below steps:
I just create the error fail1 with message containing a different character.
Go to set variable : Create a variable and added dynamic content to the value.
#replace(replace(string(activity('Fail1').output.message),pipeline().parameters.quote,'"'),'\','/')
Output:
Updated:
Parameter

How to pass variable between Chef resource blocks of same recipe

We have a Chef recipe with a couple resource blocks. The first resource block is in bash and gets the value of the UUID of a logical volume and stores into variable $uuid.
# Get UUID value
bash 'get uuid' do
cwd "/"
code <<-EOH
uuid=$(blkid -o value -s UUID /dev/vg_volgroup/lv_logicalvolume)
EOH
end
We need to pass the variable $uuid to our second resource block:
# Mount directory, format, update fstab
mount node['mount_dir'] do
dump 1
pass 2
device #{uuid}
device_type :uuid
fstype node['fstype']
options node['options']
action [ :mount, :enable]
end
Unfortunately, this is not working. The value of $uuid is not getting passed into the second resource block.
Is there a more proper way to reference $uuid from within the second resource block? Is what I'm asking even possible?
UUID is part of filesystem2 Ohai data:
filesystem2:
by_device:
/dev/md1:
...
uuid: f49a3dc8-a0b6-4e1c-8cd3-926fa7d8ee29
There is no need to run blkid for this.
However, if you really need to do compute something in a block and use it later, you could declare uuid variable before the block and use ruby_block instead. You can also use node variable inside a ruby block. Anyway, you will be affected by Chef's two pass model and it would require further workarounds (like lazy attributes).
There is also a option to use helper method, but since UUID is part of Ohai data, I do not see any reason to even try (in this case).

Powershell Replace fail after test for null

I'm pulling data from a database (access specifically using ADO). Then I am preparing the variable for possible insertion into SQL later by replacing any existing single quotes with two single quotes.
Because the value coming from the database is very likely to be null, I test for it and the replace is only supposed to happen if it is NOT null. The value I'm getting it not registering as null when I test it, but when I try the replace, I get the error
Method invocation failed because [System.DBNull] does not contain a method named 'Replace'.
Here's the section of code $OldAbstract = $rs.Fields.Item("MetaAbstract").value
if($OldAbstract -ne $null) {$OldAbstract = $OldAbstract.Replace("'","''")}
After pulling the value, I print it and it looks like nothing. I tested it for null, and it says it's not. I tested it for "" and it's not. I even checked to see if it was a space, and it's not. The length is reported as 1... I'm at a loss as to what's going on.
You're testing for the wrong type of null - PowerShell/.net null instead of a database null. Try this (untested):
$OldAbstract = $rs.Fields.Item("MetaAbstract").value
if($OldAbstract -isnot [System.DBNull]) {$OldAbstract = $OldAbstract.Replace("'","''")}

Matlab: How to remove the error of non-existent field

I am getting an error when running matlab code. Here I am trying to use one of the outputs of previous code as input to my new code.
??? Reference to non-existent field 'y1'.
Can anyone help me?
A good practice might be to check if the field exists before accessing it:
if isfield( s, 'y1' )
% s.y1 exists - you may access it
s.y1
else
% s.y1 does not exist - what are you going to do about it?
end
To take Edric's comment into account, another possible way is
try
% access y1
s.y1
catch em
% verify that the error indeed stems from non-existant field
if strcmp(em.identifier, 'MATLAB:nonExistentField')
fprintf(1, 'field y1 does not exist...\n');
else
throw( em ); % different error - handle by caller?
end
end
Have you used the command load to load data from file(s)?
if yes, this function overwrite your current variables, therefore, they become non-existent, so when you call, it instead of using:
load ('filename');
use:
f=load ('filename');
now, to refer to any variable inside the loaded file use f.varname, for
example if there is a network called net saved within the loaded data you may use it like:
a = f.net(fv);
I would first explain my situation and then give the solution.
I first save a variable op, it is a struct , its name is coef.mat;
I load this variable using coef = load( file_path, '-mat');
In a new function, I pass variable coef to it as a parameter, at here, the error Reference to non-existent field pops out.
My solution:
Just replace coef with coef.op, then pass it to the function, it will work.
So, I think the reason behind is that: the struct was saved as a variable, when you use load and want to acess the origin variable, you need point it out directly using dot(.) operation, you can directly open the variable in Matlab workspace and find out what it wraps inside the variable.
In your case, if your the outputs of previous code is a struct(It's my guess, but you haven't pointed out) and you saved it as MyStruct, you load it as MyInput = load(MyStruct), then when use it as function's parameter, it should be MyInput.y1.
Hops it would work!
At first load it on command window and observe the workspace window. You can see the structure name. It will work by accessing structure name. Example:
lm=load('data.mat');
disp(lm.SAMPLE.X);
Here SAMPLE is the structure name and X is a member of the structure