Skip to main content

All Questions

1 vote
2 answers
74 views

PowerShell, using a function to invoke a switch in a script

I'm trying to write a simple logging script to save todo items to a log file that I can quickly reference, I save the following as ~\mytodo.ps1 $input = $args $date = Get-Date -Format "dd-MM-yyyy&...
YorSubs's user avatar
  • 3,742
0 votes
2 answers
117 views

Problems with Char type and switch case

I'm trying to make a calculator with functions, and I use the symbols '+' '-' '/' '*' to select the operations, and 'x' to close the program. If I insert any other value, the program will ask to ...
Gianluca Mennella's user avatar
0 votes
2 answers
139 views

declaring switch statement and then calling it later

I've developed a code that creates concentric rectangles of alphabets based on the input, unfortunately as there's no dictionary function in C, I've used switch statement to convert my numerical value ...
Anubhav Shriwastava's user avatar
0 votes
2 answers
99 views

How to convert a string that currently has a switch parameter into a function in powershell

I have a string like this: "CleanUp -All" How do you convert it into a callable function in PowerShell including the switch? I tried calling "&" in front of the entire string. ...
davidprogrammercdn's user avatar
0 votes
1 answer
51 views

Switch case failing to call recursively another function

I am trying to call recursively another function "cityname()" with switch case#1 and I am getting "TypeError: cityname is not a function" the purpose is to give users option to ...
Mohammed Naseer Ahmed's user avatar
1 vote
1 answer
33 views

Unique phrase for customer

I have function where I'm creating one of the cases randomly, but I want when I start the app It will only generate the message once and when I will open it again it will be the same but not different....
Mário Markovič's user avatar
-1 votes
1 answer
48 views

Switch in a function

I am supposed to build a simple function where a character's level determines their health. so: It returns the number 100 if level is 0 It returns the number 150 if level is 1 It returns the number ...
eric toll's user avatar
0 votes
1 answer
37 views

Return value not showing from switch

Could someone help me understand why the first function works while the second one returns undefined? I'm confused as to why the second setup doesn't work, wouldn't it run and return the same add/...
DKXP's user avatar
  • 61
1 vote
1 answer
36 views

How should a random function be chosen to be run?

I have several functions and want to choose one randomly to run. I am using Go. Currently I am using a switch statement. This does not feel ideal because if I want to add another function I have to ...
Philip Waldman's user avatar
0 votes
2 answers
131 views

Syntax error missing semicolon in switch inside function

void placeSlagschip(){ switch(organizationBoats){ case 1: positionSlagschip = { {BOARD[0, 0], BOARD[1, 0]}, {BOARD[0, 1], BOARD[1, 0]}, ...
Donerre's user avatar
  • 11
1 vote
1 answer
59 views

Why isn't the background colour changing? (JS)

I'm new to programming, and stackoverflow, so I apologize if my question isn't in the correct format. I'm working with code which was partially written by my professor, with directions included from ...
Shaun J's user avatar
  • 11
0 votes
2 answers
377 views

Using lambda function to switch between different functions in python gives TypeError if invalid function name is given with argument

I recently learned lambda functions and switch case and I'm playing with them to understand better. Here, I'm trying to use lambda function to switch between different functions in python like the ...
cerjq's user avatar
  • 3
-3 votes
1 answer
44 views

this function only adds numbers and I can not figure why?

this function only adds numbers and I can not figure why ? function calculate($num1 , $num2 , $name = "+" ) { switch ($name) { case "+" || "add" || "a&...
Ezzeldien Magdy's user avatar
-1 votes
2 answers
98 views

a calculator in functions

I am trying to write a calculator using functions for each operation and switch case in c language but output is as follows: for example when i enter 5 and 6, and choose addition it prints sss5.000000 ...
Dilara Aydogmus's user avatar
-2 votes
2 answers
108 views

How to do switch case with return value in function with char in C programming?

I am new to C programming, trying to do an Assignment for my class. I am trying to return char value in this function while using switch case. As an example, if i were to to put 'a', i expect 'b' to ...
Mizan Shah's user avatar

15 30 50 per page
1
2 3 4 5
19