Similar Threads:
1.Reply: expect procedure name in procedure call(newbie)
You are calling a function as though it were a procedure. This is
alright in C and C++, where the result is just silently thrown away,
but in Ada you have to do something with the result, such as assign it
or use it in a subsequent expression or routine call.
2.calling non-PURE procedures in PURE procedures
In Fortran 95, a PURE procedure cannot call an intrinsic FUNCTION or
SUBOUTINE that is not PURE. The non-PURE instrinsic procedures I know
of are
DATE_AND_TIME
SYSTEM_CLOCK
RANDOM_NUMBER
RANDOM_SEED
Are there others?
Lahey/Fujitsu Fortran 95 does not catch the error of non_PURE
intrinsic functions in PURE procedures, nor did earlier versions of
Compaq Visual Fortran, but CVF 6.6C DOES catch the error. I found some
bugs in my code when upgrading from CVF 6.6 to CVF 6.6C.
The code below, saved in "nonpure.f", compiles without error for LF95
but not CVF 6.6C (which is the correct behavior).
LF95 compilation:
lf95 -c -nfix -f95 -nco nonpure.f
Lahey/Fujitsu Fortran 95 Express Release 5.70c
Compiling program unit nonpure_module at line 1:
Encountered 0 errors, 0 warnings in file nonpure.f.
Compiling file nonpure.f.
CVF compilation:
df -c -free -stand:f95 nonpure.f
Compaq Visual Fortran Optimizing Compiler Version 6.6 (Update C)
Copyright 2003 Compaq Computer Corp. All rights reserved.
nonpure.f
nonpure.f(7) : Error: Any procedure referenced in a PURE procedure,
including one referenced via a defined operation or assignmnent, must
be explicitly declared PURE. [DATE_AND_TIME]
call date_and_time(xdate)
-----^
nonpure.f(12) : Error: Any procedure referenced in a PURE procedure,
including one referenced via a defined operation or assignmnent, must
be explicitly declared PURE. [RANDOM_NUMBER]
call random_number(x)
-----^
nonpure.f(16) : Error: Any procedure referenced in a PURE procedure,
including one referenced via a defined operation or assignmnent, must
be explicitly declared PURE. [RANDOM_SEED]
call random_seed()
-----^
nonpure.f(21) : Error: Any procedure referenced in a PURE procedure,
including one referenced via a defined operation or assignmnent, must
be explicitly declared PURE. [SYSTEM_CLOCK]
call system_clock(ic)
-----^
! begin file nonpure.f
module nonpure_module
implicit none
contains
!
pure subroutine xdate_and_time()
character (len=8) :: xdate
call date_and_time(xdate)
end subroutine xdate_and_time
!
pure subroutine xrandom_number()
real :: x
call random_number(x)
end subroutine xrandom_number
!
pure subroutine xrandom_seed()
call random_seed()
end subroutine xrandom_seed
!
pure subroutine xsystem_clock()
integer :: ic
call system_clock(ic)
end subroutine xsystem_clock
end module nonpure_module
3.How to make a procedure call from another procedure
It is really simple:
proc example {} {puts "hello!"}
proc test {procname} {
$procname
}
% test example
hello!
4.How to make a procedure call from another procedure
Hi,
I am new to Tcl/Tk and have a little prob. I have to make a procedure
call (within another procedure).The name of the procedure is stored in
a variable and it doesn't take any arguments. To be more clear, I have
a variable "procName" which stores the name of the procedure and I have
to call this procedure from another procedure say, "Proc1". I tried
writing
$procName
within the procedure "Proc1" but this does not make a call to the
specified procedure. How should I go about it?
Regards
-RG
5.Expect - hangs when called from a nested procedure.
Running Active Tcl 8.4.14 on Windows XP.
Are there any known issues with Expect when called from a 2 level
nested procedure? I have an FTP Expect script that hangs when the
calling script is moved to a procedure.
E.G This works - top level script calls dialog procedure(see below
for dialog proc details.
expectFTP,tcl
.................
.................
set variables
spawn ftp $host
set prompt "(Name|login|Login|Username|User).*:.*"
set sendString "$user1"
# call diaglog proc
dialog $spawn_id $prompt $sendString
#set prompt "Password:"
set sendString "$userpassword1"
#call dialog proc
dialog $spawn_id $prompt $sendString
E.G This fails - top level script calls expectFTP_proc procedure
which calls dialog proc details. The "spawn" creates the FTP
connection, identifies the "User" prompt and submits the "userid" send
string but then the script hangs on "Password". The debug output
indicates that there is no response from the "userid" send so the FTP
server waits for the userid while Expects looks for the password
prompt.
This only occurs when the code that calls dialog.proc is moved from
the top level script into a procedure.
I can email the complete script is anyone is interested .
Thanks.
Patrick.
expectFTP,tcl
.................
.................
set variables
# call expectFTP_proc
expectFTP_proc
set variables
spawn ftp $host
set prompt "(Name|login|Login|Username|User).*:.*"
set sendString "$user1"
# call diaglog proc
dialog $spawn_id $prompt $sendString
#set prompt "Password:"
set sendString "$userpassword1"
#call dialog proc
dialog $spawn_id $prompt $sendString
==================================================
proc dialog { ftpSpawnId prompt sendString } {
global ftpErrorMatch
puts \n
puts "spawnid is $ftpSpawnId"
puts "expected prompt is $prompt"
puts "sendString is $sendString"
exp_log_user 1
expect {
-i $ftpSpawnId
-re $prompt {
puts "matched on prompt"
exp_send "$sendString\r"
exp_send_user "$sendString\n"
}
"Unknown host" {
puts "ERROR: Unknown host"
expect *
error "Expected: '$prompt'. Saw: $expect_out(buffer)"
}
$ftpErrorMatch {
puts "ERROR: FTP Error"
expect *
error "Expected: '$prompt'. Saw:
$expect_out(buffer)"
}
timeout {
puts "ERROR: timeout exceeded"
expect *
error "Expected: '$prompt'. Saw: $expect_out(buffer)"
}
eof {
expect *
error "Expected: '$prompt'. Saw: $expect_out(buffer)"
}
}
return [ array get expect_out ]
}
6. How to create a procedure that takes another procedure with an argument
7. procedure as argument in procedure
8. Nested procedures and procedure parameters