A subroutine (e.g. procedure or subprogram) is a portion of code within a larger program, which performs a specific task and can be relatively independent of the remaining code. The syntax of many programming languages includes support for creating self contained subroutines, and for calling and returning from them. They are in many ways similar to functions, but usually have side-effects outside of the simple "return value" that functions return.
Questions tagged [subroutine]
1255 questions
-1
votes
1 answer
How to create a unit test in Perl?
I am trying to create a unit test for this error post subroutine shown below. This method takes in the error name and prints out the message which is a value located in each error. This is the code I have:
use constant {
# link included…

Paul Russell
- 179
- 10
-1
votes
1 answer
Error: calling a sub(routine) from a different sub in VB
I am trying to make the program execute multiple times (instead of just once when the form loads); I have tried to do this through either the user clicking a button, or a timer that would execute the program again after it has "ticked".
I have…

AntonyBoys
- 15
- 3
-1
votes
2 answers
Returning a hash of the Parsed document (using Twig in Perl) to be used for processing in other subs
I am failing terribly to return a Hash of the Parsed XML document using twig - in order to use it in OTHER subs for performing several validation checks. The goal is to do abstraction and create re-usable blocks of code.
XML Block:

MSalman
- 13
- 5
-1
votes
2 answers
Unable to Call Subroutine
I am unable to call sub BCD if user input valid week number in userform. If user input invalid or empty week number, sub BCD will execute.
What wrong with my code?
Private Sub cmdOK1_Click()
Call ABC
Call BCD
End Sub
Sub ABC()
'Prompt message…

cklim
- 1
- 1
-1
votes
2 answers
Global Symbol requires package name while using "my" in Sub
I have a class where we are learning Perl so forgive me if I made a simple/obvious error as I am still learning. My question is why do I get the error
Global Symbol "%localhash" requires explicit package name
as well as the same error for "$param"…

Robert Rodriguez
- 1
- 1
-1
votes
1 answer
Returning an alias from a subroutine in Perl
Is it possible to return an alias from a subroutine in Perl?
I have a simple example:
#!/usr/bin/perl
use warnings;
use strict;
use feature qw{ say };
{
package Test;
my $value = 'old';
sub get_value {
return \$value;
}
…

tjwrona1992
- 8,614
- 8
- 35
- 98
-1
votes
1 answer
how do i get a reference to the a sub routine within a module
I need to find out how to reference a Subroutine within another module by a reference. This is what I am trying to do:
Module Mod1
sub_x(pass a reference to this module)
Private Sub close_me()
' do something here
End Sub
End…

John
- 1,310
- 3
- 32
- 58
-1
votes
1 answer
Best or most efficient way to sort parallel arrays using subroutines in C?
Ok so the user enter a name and an age. The output needs printed in ascending order. I've done bubble sort but I do not know how to keep track of the ages with the names. Is one sort method better or easy than another one?

IdislikeCalot
- 41
- 1
- 9
-1
votes
1 answer
Perl : Passing Arrays as arguments
I have written a function and the function call works as expected and i get the desired output when i make the function call. However I'd like to enhance it by making a couple of changes to it. For now the function takes 'ip' and 'service names' as…

user3587025
- 173
- 1
- 4
- 17
-1
votes
1 answer
calling a subroutine in scheme
I'm trying to call a subroutine from a function on scheme this what i have so far.
(define (main)
(display "Ingrese un parametro: ")
(define x (read-line))
(newline)
(display "Ingrese una posicion: ")
(define dig (read))
(newline)
(if (string? x)
…

user3762282
- 57
- 4
-1
votes
1 answer
set unset variable, scope CMD Script Windows, routines
I want to know how solve this:
rem declaring variable
set "vara="
echo vara:%vara% bef
call :myroutine
echo vara:%vara% aft
:routine
rem ...
rem assing value to variable vara
set "vara=34"
echo vara was assigned...
rem ....
echo vara:%vara%
exit…
user1410223
-1
votes
2 answers
How to set to zero all variables at each call of subroutine?
Is there some simple way to initiate group of variables in Fortran subroutines? Something like DATA but working each time when subroutine is called. Or the only solution is to use x = 0.0 for all variables?
-1
votes
1 answer
SubForm won't Requery after MainForm Changes are made
I have an access 2010 database that has a main form 'MainForm' and a subform 'SubForm'. The SubForm is attached to the MainForm as a Subform/Subreport object. The user will select a unique identifier from a dropdown and the subform should use that…

designspeaks
- 203
- 2
- 11
- 22
-1
votes
1 answer
Pass lines from 2 files to same subroutine
I'm in the process of learning how to use perl for genomics applications. I am trying to clean up paired end reads (1 forward, 1 reverse). These are stored in 2 files, but the lines match. What I'm having trouble doing is getting the relevant…

aupadhyaya
- 31
- 3
-1
votes
1 answer
Fortran tips in large modules
I have a module that consists of many small subroutines and one main subroutine, which is the only one that is public. The rest of the subroutines are private and called by the main subroutine or within them. The main subroutine has to take all the…

Michael
- 1,834
- 2
- 20
- 33