Google Apps script - Checkbox to open a prefilled google form link - urlfetch

I have created a script that when I click on a checkbox on column "A" it then goes to column "B" to open the link in that same row. The script also clears the checkbox and two other cells in the same row. I also have an installed "onedit" trigger for the script. The script is currently working, the only thing is that sometimes it executes fast and other times it stalls and it executes slow. Can you please guide me on making the script execute fast every time without stalling. Thank you for your help! See script and picture below:
A column and B column picture
`function urlonEdit(e) {
const src = e.source.getActiveSheet();
const r = e.range;
if (src.getName() != "ROLL CALL" || r.columnStart != 1 || r.rowStart <= 2 || !r.isChecked()) return;
let url = src.getRange(r.rowStart, 2, 1, 1).getValues();
src.getRange(r.rowStart, 1, 1, 1).clearContent();
src.getRange(r.rowStart, 13, 1, 1).clearContent();
src.getRange(r.rowStart, 14, 1, 1).clearContent();
let response = UrlFetchApp.fetch(url);`}

Related

Saving synchronised 7T fMRI Triggers received via USB connected NNL SyncBox, on every TR and Task Response Keypress (PsychoPy)

I would like to get synchronised timings and number of triggers for each single pulse sent by the 7T MRI scanner together with each single SPACEBAR keypress as a participant’s response when particular letters (A, B, C, X, Y) are presented on the screen, also the stimulus start time with each corresponding trigger.
So far I have added a “Waiting for scanner” routine where I get the first pulse via USB connected NNL Synbox saved in the .csv data file but I want to save each single pulse (TR) and timings. Triggers are automatically emulated as letter ‘s’ sent by the NNL Synbox.
# Code component: Creat routine "Wait for Scanner"
text_wait = visual.TextStim(win=win, name='text_wait',
text='Waiting for scanner...',
font='Arial',
pos=(0, 0), height=0.8, wrapWidth=None, ori=0,
color='white', colorSpace='rgb', opacity=1,
languageStyle='LTR',
depth=0.0);
#Set first MR Trigger
mr_trigger_number = [] # list for triggers
mr_trigger_time = [] # list for time of each trigger
ScannerKeyboard = keyboard.Keyboard() # set keyboard
count_mr_trigger = 0 # counts amount of MR scanner trigger, starts with zero
start_trigger = ScannerKeyboard.getKeys(keyList=['s'], waitRelease = False) # experiment starts with MR Scanner "s"
# Draw waiting Screen until "s" is sent from NNL Syncbox
while len(start_trigger) == 0: # if no trigger was sent show:
text_wait.draw() # Text "Waiting for scanner"
win.flip()
start_trigger = ScannerKeyboard.getKeys(keyList=['s'], waitRelease = False) # show text_wait until one "s" was received
# Get timing information and store trigger number
onset = core.getTime() # get Onset time of trigger
count_mr_trigger = count_mr_trigger + 1 # count MR Scanner trigger, add "1!
# Save time and number of MR Trigger
thisExp.addData('MR_trigger_time',onset) # save trigger time of onset
thisExp.addData('MR_trigger_number',count_mr_trigger)
And also I used the following code component in > Each Frame tab of 2 trials conditions to save the stimuli onset timings when a pulse 's' is received. This works fine but stimulus start time > stimulus_start_time = globalClock.getTime() - mr_trigger_time is saved based on first pulse only as I am unable to save each pulse timings.
#save stimulus onset time for two types of trial conditions
if trials.thisN == 0 and frameN == 0:
loop_start_time = globalClock.getTime() - mr_trigger_time
elif frameN == 1:
stimulus_start_time = globalClock.getTime() - mr_trigger_time
# store the data:
thisExp.addData('stimulus_start_time', stimulus_start_time)
if trials_2.thisN == 0 and frameN == 0:
loop_start_time = globalClock.getTime() - mr_trigger_time
elif frameN == 1:
stimulus_start_time = globalClock.getTime() - mr_trigger_time
# store the data:
thisExp.addData('stimulus_start_time', stimulus_start_time)
However, I want to record and save timings of each trigger pulse when a SPACEBAR response is pressed on a target letter (stimulus) by a participant, to compare the timings with accuracy and reaction times of the task with each corresponding trigger timings.
I would really appreciate your valuable suggestions on how to work around this, as I am quite new to the PsychoPy. I also posted to the PsychoPy forum but haven't got any update so far.
Thanks in advance!

Call an attribute from a Matlab script in AppDesigner GUI

I have created a GUI with app designer which launch a matlab program after the user chose a file and pressed launch button :
function LaunchButtonPushed(app, event)
app.ResultWindowTextArea.BackgroundColor = 'green';
app.ResultWindowTextArea.FontSize = 20;
app.ResultWindowTextArea.Value = 'Launch of the program ...';
testLectureXML(app.FileTextArea.Value{:});
if n_component == 0
app.ResultWindowTextArea.BackgroundColor = 'red';
app.ResultWindowTextArea.Value = 'Please choose a valid File !';
stop testLectureXML()
end
end
n_component is an attribute in my testLectureXML matlab program and he is equal to 0 only if the file that the user chose is empty. But it's like my application doesn't recognize n_componentas the attribute of my testLectureXMLprogram.
And if possible, if n_component = 0 i would like to stop the program
How can i do this ? Thanks !
Edit : To stop the programm i have thinking of creating exitProgram = 0 and if exitProgram = 1 return 0and in the GUI code i just put exitProgram = 1 if the file is empty but i don't know how to access to an attribute of a matlab script with GUI code.

Group team change scripts that work currently?

Any working roblox team change GUIs that you have to be in a certain group to change teams in?
Hi there, I've spent 20 minutes to code a team-changing GUI for you, follow my steps below for it to work. (This is FilteringEnabled friendly)
Step 1 Insert a LocalScript into StarterGui
Step 2 Copy the stuff from LocalScript below and paste it into your LocalScript
Step 3 Insert a Script into either Workspace or ServerScriptService (your choice)
Step 4 Copy the stuff from ServerScript below and paste it into your script
ServerScript
local teams = game:GetService("Teams")
local settings = {
["GUIHeight"] = 30, --put in a number over 20, or 100 if you want it to fill the screen
["GUIWidth"] = 40, --put in a number over 20, or 100 if you want it to fill the screen
["GUIColor"] = Color3.fromRGB(240,240,240), --color of the team changer gui
["TitleText"] = "Team Changer", --title text in the gui
["TitleFont"] = "ArialBold", --font of title
}
repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.PlayerGui
local plr = game.Players.LocalPlayer
local teamGUI = Instance.new("ScreenGui",plr.PlayerGui)
local frame = Instance.new("Frame",teamGUI)
frame.AnchorPoint,frame.Size,frame.Position,frame.BackgroundColor3 = Vector2.new(0.5,0.5),UDim2.new(settings.GUIWidth/100,0,settings.GUIHeight/100,0),UDim2.new(0.5,0,0.5,0),settings.GUIColor
local title = Instance.new("TextLabel",frame)
title.Text,title.Font,title.Size,title.TextScaled,title.BackgroundTransparency = settings.TitleText,settings.TitleFont,UDim2.new(1,0,0.15,0),true,0.5
local closebutton = Instance.new("TextButton",title)
closebutton.Size,closebutton.Position,closebutton.BackgroundColor3,closebutton.Text = UDim2.new(0.1,0,1,0),UDim2.new(0.9,0,0,0),Color3.fromRGB(255,155,155),"Close"
local list = Instance.new("ScrollingFrame",frame)
list.Size,list.Position,list.BackgroundTransparency = UDim2.new(1,0,0.85,0),UDim2.new(0,0,0.15,0),1
local UILayout = Instance.new("UIListLayout",list)
local serverTeamHandler = game.ReplicatedStorage:WaitForChild("teamChanger")
local getTeams = teams:GetChildren() --this part checks if you have teams in your game (you need to have put the teams in your game already)
for i,v in pairs(getTeams) do
print("[Team " .. i .. " found]: " .. v:GetFullName())
local teamButton = Instance.new("TextButton",list)
teamButton.BackgroundColor3 = v.TeamColor.Color
teamButton.Size = UDim2.new(1,0,0,40)
teamButton.Text,teamButton.TextColor3,teamButton.TextStrokeTransparency,teamButton.TextScaled = v.Name,Color3.fromRGB(255,255,255),0.7,true
teamButton.MouseButton1Down:connect(function()
print("You changed teams. You are now in: " .. v.Name)
serverTeamHandler:InvokeServer(v)
end)
end
closebutton.MouseButton1Click:connect(function()
frame:TweenPosition(UDim2.new(0.5,0,2,0),"Out","Quad",0.5)
local returnButton = Instance.new("TextButton",teamGUI)
returnButton.Size,returnButton.Position,returnButton.Text,returnButton.TextScaled = UDim2.new(0,200,0,50),UDim2.new(0.5,-100,1,-50),"Open Team Changer",true
returnButton.MouseButton1Down:connect(function()
returnButton:Destroy()
frame:TweenPosition(UDim2.new(0.5,0,0.5,0),"Out","Elastic",1,true)
end)
end)
LocalScript
local teamChanger = Instance.new("RemoteFunction",game.ReplicatedStorage)
teamChanger.Name = "teamChanger"
local function changeTeam(client,team)
print(client.Name .. "changed teams: now in" .. team.Name)
client.Team = team
end
teamChanger.OnServerInvoke = changeTeam
If you followed these steps correctly, you should now have a working team changing GUI in your game! It works as long as you have already inserted Teams in your game. The first few lines in the LocalScript can also be customized as well!

How do I make a working team changer GUI in roblox?

In 2018 Roblox switched coding platforms I believe, most scripts have survived, however I have failed to find a working team changer for myself this year that changes your team when clicked depending if you are in certian groups or not. My scripter says that it works in studio, but an error pops up in game that says "
TeamColor is not a valid member of PlayerGui
Stack Begin
Script 'Players.Benyal.PlayerGui.Starter GUI.TeamGui.Frame.Research and Development.LocalScript', Line 8
Stack End"
My scipter tried many different ways but it just wont work! Any seggustions?
This solution uses two scripts (one LocalScript and one Script), follow the steps below to make a team changing GUI!
local teams = game:GetService("Teams")
local settings = {
["GUIHeight"] = 30, --put in a number over 20, or 100 if you want it to fill the screen
["GUIWidth"] = 40, --put in a number over 20, or 100 if you want it to fill the screen
["GUIColor"] = Color3.fromRGB(240,240,240), --color of the team changer gui
["TitleText"] = "Team Changer", --title text in the gui
["TitleFont"] = "ArialBold", --font of title
}
repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.PlayerGui
local plr = game.Players.LocalPlayer
local teamGUI = Instance.new("ScreenGui",plr.PlayerGui)
local frame = Instance.new("Frame",teamGUI)
frame.AnchorPoint,frame.Size,frame.Position,frame.BackgroundColor3 = Vector2.new(0.5,0.5),UDim2.new(settings.GUIWidth/100,0,settings.GUIHeight/100,0),UDim2.new(0.5,0,0.5,0),settings.GUIColor
local title = Instance.new("TextLabel",frame)
title.Text,title.Font,title.Size,title.TextScaled,title.BackgroundTransparency = settings.TitleText,settings.TitleFont,UDim2.new(1,0,0.15,0),true,0.5
local closebutton = Instance.new("TextButton",title)
closebutton.Size,closebutton.Position,closebutton.BackgroundColor3,closebutton.Text = UDim2.new(0.1,0,1,0),UDim2.new(0.9,0,0,0),Color3.fromRGB(255,155,155),"Close"
local list = Instance.new("ScrollingFrame",frame)
list.Size,list.Position,list.BackgroundTransparency = UDim2.new(1,0,0.85,0),UDim2.new(0,0,0.15,0),1
local UILayout = Instance.new("UIListLayout",list)
local serverTeamHandler = game.ReplicatedStorage:WaitForChild("teamChanger")
local getTeams = teams:GetChildren() --this part checks if you have teams in your game (you need to have put the teams in your game already)
for i,v in pairs(getTeams) do
print("[Team " .. i .. " found]: " .. v:GetFullName())
local teamButton = Instance.new("TextButton",list)
teamButton.BackgroundColor3 = v.TeamColor.Color
teamButton.Size = UDim2.new(1,0,0,40)
teamButton.Text,teamButton.TextColor3,teamButton.TextStrokeTransparency,teamButton.TextScaled = v.Name,Color3.fromRGB(255,255,255),0.7,true
teamButton.MouseButton1Down:connect(function()
print("You changed teams. You are now in: " .. v.Name)
serverTeamHandler:InvokeServer(v)
end)
end
closebutton.MouseButton1Click:connect(function()
frame:TweenPosition(UDim2.new(0.5,0,2,0),"Out","Quad",0.5)
local returnButton = Instance.new("TextButton",teamGUI)
returnButton.Size,returnButton.Position,returnButton.Text,returnButton.TextScaled = UDim2.new(0,200,0,50),UDim2.new(0.5,-100,1,-50),"Open Team Changer",true
returnButton.MouseButton1Down:connect(function()
returnButton:Destroy()
frame:TweenPosition(UDim2.new(0.5,0,0.5,0),"Out","Elastic",1,true)
end)
end)
Step 1 Insert a LocalScript into StarterGui
Step 2 Copy the stuff above and paste it into this LocalScript
Step 3 Insert a Script into either Workspace or ServerScriptService (your choice)
Step 4 Copy the stuff below and paste it into the Script
local teamChanger = Instance.new("RemoteFunction",game.ReplicatedStorage)
teamChanger.Name = "teamChanger"
local function changeTeam(client,team)
print(client.Name .. "changed teams: now in" .. team.Name)
client.Team = team
end
teamChanger.OnServerInvoke = changeTeam
If you followed these steps correctly, you should now have a working team changing GUI in your game! It works as long as you have already inserted Teams in your game. The first few lines in the LocalScript can also be customized as well!

Panel doesn't execute )PNTS Section

I'm coding a ISPF Panel with "Point and shoot" elements. The elements say "yes" and "no" and the default cursor have to point to "yes".
1st Case:
Declaration of the fields: + TYPE(INPUT) PAS(ON)
When I use this declaration, the panel closes by pressing [enter] and generating rc = 0. However, the )PNTS section doesn't run.
2nd CASE:
Declaration of the fields: + TYPE (PS)
The )PNTS section runs by pressing [enter]. However, I cannot set the .cursor to the field "yes".
I tryed different ways with different field names (e.g. ZPS00001). I tryed to simulate Point and Shoot with Rexx, but nothing worked really fine.
Pressing enter will cause the point and shoot fields to be processed. However the cursor must be on one of the fields for the )PNTS section to set the value associated with a field. It would sound like panel may have not been coded correctly. PAS should be used for input or output fields and PS should be used for text fields. For instance if you have the following panel:
)ATTR
$ TYPE(PS)
! TYPE(OUTPUT) PAS(ON)
)BODY
+ --------------------- +
+ ===>_ZCMD +
+
$Field1 : _FLD +
$Field2 : _ABC +
$Field3 : !IN1 +
$Field4 : !IN2 +
)INIT
&INV1 = 111
&INV2 = 222
&INV3 = 333
)REINIT
REFRESH(*)
)PROC
)PNTS
FIELD(IN1) VAR(INV1) VAL(ON)
FIELD(IN2) VAR(INV2) VAL(OFF)
FIELD(ZPS00001) VAR(INV3) VAL(1)
FIELD(ZPS00002) VAR(INV3) VAL(2)
FIELD(ZPS00003) VAR(INV3) VAL(3)
FIELD(ZPS00004) VAR(INV3) VAL(4)
)END
With the following REXX exec:
/* REXX */
RCC = 0
INV1 = 0
INV2 = 1
DO WHILE RCC = 0
ADDRESS ISPEXEC 'DISPLAY PANEL(PAS)'
RCC = RC
SAY INV1 '-' INV2 '-' INV3
END
You can test the values of inv1, inv2 and inv3 based on where you put the cursor when you hit enter. You will get 1, 2, 3 or 4 if the cursor in on field1, field2, field3 or field4. If it is on IN1 or IN2 then you get ON or OFF. It all depends on where the cursor is positioned when ENTER is hit. Based on the example you can see point and shoot is not limited to Menus. Hope the example helps.
Marv Knight