问题标签 [subroutine]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
perl - Perl:如何检查从子例程返回的内容
我有一个子程序,当一切顺利时会返回两个哈希值。但是命令的子结帐输出,如果它与某个模式匹配,则返回“-1”。无论如何要检查我调用它的子程序的返回吗?
有点像:
perl - 如何编写 Perl 脚本来提取 Perl 包中每个子例程的源代码?
给定一个 Perl 包 Foo.pm,例如
如何编写脚本来提取每个子的文本源代码,从而产生哈希:
我希望文本与包装、空格和所有内容中出现的完全相同。
谢谢。
function - Fortran 90/95 中的函数接口
我有一个程序调用一个子程序,然后调用一个函数。Fortran 对函数类型声明的要求让我有些困惑。我已经在函数中声明了类型(即真正的函数 foo(...)),并且无论我是否在子例程声明部分中声明了该函数,程序都可以正常工作。
我的具体问题是,在子例程中声明该函数是否可能会导致将来出现意外行为?我也看到了接口块,想知道这是否也有必要。
更一般地说,我还对 Fortran 在“幕后”所做的事情以及为什么声明函数或使用接口块或多或少很重要感兴趣。
编辑:一些示例代码:
batch-file - 在批处理脚本中对标签使用 CALL
当使用 CALL 命令调用批处理脚本中的标签,并使用 GOTO:eof 结束子例程时,从那里会发生什么?它是否返回到子例程的 CALL 所在的位置?还是在调用脚本的位置之后继续?
例如:
在 GOTO:e 之后它将回显哪一行?
perl - 排除 perl 子例程和 dbi 错误
继续unable to connect error
调用我的第二个子程序。
我正在使用 2 个子例程,其中主要检查 sub 1 的结果,如果设置了条件,则运行 sub 2。我可以看到启动 sub 2 的值是正确的(进行打印)
两个潜艇都非常相似。我不确定这在哪里失败。
fortran - Smart way to pass arguments in Fortran 90
I am a Fortran novice. I am trying to write a subroutine that will take in four arguments from the main program, and then outputs to the main program an array that involves the four arguments that were originally passed in. What is a good/smart way to do this?
For example, in my test program below, I create four real variables (a
, b
, c
, and d
) in the main program. Then I pass these real variables to a subroutine called mysub
. I would like mysub
to be able to take in a
, b
, c
, and d
, use them to populate a 2-by-2 array called o
, and then send o
to the main program for displaying (and possible modification) there. So, I tried the following:
But, I get the following error:
I interpret this as, the compiler doesn't know what o
is, because o
is not in the list of arguments in the subroutine header: SUBROUTINE mysub(w,x,y,z)
. So I probably need to include o
in that header. So, I next try the following (where I have denoted changes or additions using !...
):
This seems to work fine, and I get the correct output:
But, my question is, is this a good way to do this? In this working example, I'm declaring the array o
both in the subroutine and in the main program. This seems potentially confusing, because I think that this means that I need to take care that either the subroutine or the main program allocates o
(but not both, I think, in order to avoid error messages). Is there a smarter way to do this--to send an array from a subroutine to the main program? Thank you for your time.
perl - 传递给子例程时Perl引用和延迟哈希值?
我已经在这个问题上纠结了大约 5 个小时,我真的很沮丧,需要一些帮助。
我正在编写一个 Perl 脚本,它从 MySQL 表中提取作业,然后执行各种数据库管理任务。当前任务是“创建数据库”。该脚本成功地创建了数据库,但是当我为 PHP 开发人员生成配置文件时,它就崩溃了。
我认为这是引用和取消引用变量的问题,但我不太确定到底发生了什么。我认为在这个函数调用之后,$$result{'databaseName'} 发生了一些事情。这就是我得到结果的方式:$result = $select->fetchrow_hashref()
这是我的函数调用和函数实现:
函数调用(第 127 行):
功能实现:
错误:
第 142 行:
第 154 行:
我认为问题出在函数调用的原因是因为如果我注释掉函数调用,一切都会很好!
如果有人可以帮助我了解发生了什么,那就太好了。
谢谢,
ps 如果您发现将整个密码以纯文本形式存储在数据库中存在安全问题,则在正常工作后将得到解决。=P
迪伦
applescript - AppleScript - StackOverflow 错误
我今天刚开始使用applescript,听说过子程序。所以我决定编写一个小测试程序,它接受一个数字,将其加 9,减 27,除以 3,然后返回结果。只有它不返回结果;它会返回一个StackOverFlow
错误。什么是 StackOverFlow 错误?
程序编译正确,不知道哪里出了问题。就像我说的,我对 AppleScript很陌生。这是我正在运行的代码:
string - 传递字符串以在 Fortran 子例程中执行
在下面的子例程中,我想传递一个名为str
. 如果是'poly'
, 'gaus'
, 'slat'
,那么它有一个预定义的动作(fval =
见下面的代码)。我想让用户指定一个要使用的函数并将其作为字符串变量传递。
那是 ...
如果str = '3*cos(i*t)'
,那么我希望有fval
等于3*cos(i*t)
。如何让 Fortran 将输入的字符串解释为由 Fortran 执行的命令?
asp.net - 在不同的 aspx 页面中调用过程(在同一个项目中)
在我的 asp.net 项目中,我有两个特定的 aspx 页面(比如说 PageA.aspx 和 PageB.aspx)
在代码隐藏 PageA.aspx.vb 中,我想调用恰好在 PageB.aspx 中的“Sub GetDefaultValues()”
更新:
PageB.aspx 具有包含默认值的文本框控件(在 Sub GetDefaultValues 中读取)。这些默认值被填充到 PageA.aspx 的文本框中(基于某些条件)
有没有办法做到这一点?