FAQ Database Discussion Community


python: changing list value in sub-routine

python,list,subroutine,function-parameter
I have a simple example. The function test_list_change should change the list passed to it as a parameter. And inside this function there is a call to sub-routine test_list_change_2 which should change the same list. The problem is, that the result list doesn't contain changes made by the test_list_change_2 subroutine...

Backslash before a subroutine call

perl,reference,subroutine
As I was understanding the difference between [] and \ in references,I used both on subroutine the former was fine but when I tried later I thought it should give error but the below program in perl #!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @b; for my $i (...

Making a Subclass with one parameter to change a value of Parent Class

c#,inheritance,subroutine
Hi guys I need some help. I'm completely suck on how to do this with Inheritance. The aim is to change the value of 'Name' property inherited by the Parent Class (Clothing) of a shirt object. When a button is clicked withing my C# Web Form by calling the Shirt's...

Excel VBA: Stops Working at Outlook Email Creation Subroutine

excel,vba,excel-vba,outlook,subroutine
I asked this question the other day and thought I found the answer, but now Excel keeps going into it's 'Not Responding' mode. My issue is that the program runs fine on some computers, but bombs out on others. Background: This program gets run after the user fills in an...

fortran operator overloading: function or subroutine

function,fortran,operator-overloading,gfortran,subroutine
I recently updated my .f90 code to .f03, and I was expecting to see speedup because my older version involved many allocating and deallocating (7 3D arrays--45x45x45) at each iteration inside a do loop (4000 in total). Using derived types, I allocate these arrays at the beginning of the simulation...

passing hash in subroutines

perl,hash,subroutine
I have made a simple perl script for printing hash key/value pairs through subroutine #!/usr/local/bin/perl #passing hash to a subroutine sub printhash{ my (%hash) = @_; foreach my $key (keys %hash){ my $value = $hash{$key}; print "$key : $value\n "; } } %hash = {'name' => 'devendra', 'age' => 21};...

Can I run a Sub based on whether another Sub Has run? (EXCEL VBA)

excel,excel-vba,subroutine
All, I have a userform and am trying to allow my users to use two different text boxes to search a worksheet based on the value in either text box. The form populates other boxes based on the active cell. My question is: Can I write the code for the...

How do I pass by reference an array of pointers created into a struct?

c,arrays,struct,subroutine
I need to create a program that can sum N vectors and print the final array, for example, if I put N = 2, first array (a,b) and second array(c,d) the sum should be (a+c, d+b). But I cannot compile this program, it gives an error in the line 57...

how do i get a reference to the a sub routine within a module

vb.net,methods,module,subroutine
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 Module Module Mod2 Public Sub sub_x(get the reference...

The name of a subroutine can be a variable in fortran? [duplicate]

fortran,fortran90,subroutine
This question already has an answer here: How to alias a function name in Fortran 2 answers I was wondering if there is something similar to this in FORTRAN. Of course this example does not compile but I think you can get the idea, program test character(1):: sub sub='A'...

VBA Pass Array By Reference and Modify Contents

arrays,vba,function,pass-by-reference,subroutine
VBA question. I'm using it to make Solidworks macros, but that's not important. Can someone explain the syntax to pass an array (1-Dimensional of type Double, with length of three) to a subroutine or function so I can modify the contents. I know that they have to be passed by...

Why do these blocks of code behave differently?

perl,pass-by-reference,subroutine,pass-by-value,pass-by-pointer
I am new to Perl, and I cannot figure this out. I have two seemingly identical sets of code, but one subroutine updates the value while another does not. In the first set of code, my understanding is that the reference to an array is passed, then the value at...

Should a subroutine always return explicitly?

perl,function,oop,subroutine,perl-critic
If perlcritic says "having no returns in a sub is wrong", what is the alternative if they really aren't needed? I've developed two apparently bad habits: I explicitly assign variables to the '$main::' namespace. I then play with those variables in subs. For example, I might do.. #!/usr/bin/perl use strict;...

Perl: Subroutines first argument is not the class

perl,subroutine
I'm relatively new to Perl so bear with me. My sub getGenes calls getFeaturesByGeneName in the class SequenceModule. The first loop runs fine however in the second loop it tries to invoke get_SeqFeatures (a BioPerl sub) on the string $name meaning that it skips my $self = shift. What am...

I cannot print the final array from the subroutine

c,arrays,subroutine
I need to create a program that can sum N vectors and print the final array, but for example, if I put N = 2, first array (a,b) and second array(c,d) the sum should be (a+c, d+b) but it shows me only (a,b) and gives me an erro. Of course...

Call parallel fortran MPI subroutine from R

r,parallel-processing,fortran,mpi,subroutine
I would like to write some parallel Fortran code in a subroutine that can be called by R (I would like to read in data from R and send it to a parallel Fortran MPI). I have noticed, however, that when I run the following program as a subroutine (i.e....

how to get a subroutine in excel vba to return something?

excel,vba,function,subroutine
I have the following code in excel vba: Sub main() Call Get_Rows_Generic("usersFullOutput.csv", 1) End Sub in another module i have: Sub Get_Rows_Generic(work_sheet As String, column_num As Integer) Dim wsUsers As Worksheet: Set wsUsers = Worksheets(work_sheet) Dim userRows As Integer: userRows = wsUsers.Cells(Rows.Count, column_num).End(xlUp).Row MsgBox userRows End Sub How do i...

Excel Not Responding When Passing Objects To Subroutine

excel,vba,excel-vba,subroutine
This macro runs fine on most of our work computers, but NOT all of our work computers. Everyone is running Excel 2013 and on newer computers with plenty of RAM (4-8 GB). Here is the subroutine that is being called: Public Sub EmailApprovalP1(GeneralSection As Object, ItemSection As Object, VendorSection As...

perl subroutine from reading STDIN (“Press enter to reset”) only works the first time

perl,stdin,subroutine
I have made a little perl program for a kids demonstration and I'm trying to keep the screen clean and simple with a clear subroutine, but it's only working the first time, and then will not respond to input, only clearing the screen, and I can't work out why. I'm...