comcu Posted August 21, 2008 Posted August 21, 2008 can you hold a string valu when calling from sub to sub? Cheers Col. Quote
lpseifert Posted August 21, 2008 Posted August 21, 2008 If you don't declare it e.g. declared (defun test1 (/ strng1) (setq strng1 (getstring "Enter sumthin: ")) ) undeclared (defun test2 () (setq strng2 (getstring "Enter sumthin else")) ) If you load and run these functions, !strng1 will return nil [won't be available for other subs]; !strng2 will return a string [available] Quote
borgunit Posted August 21, 2008 Posted August 21, 2008 In VB you can set it to a module level variable ( ie "Private varname as string" at the top of a module) or a global variable ( ie "Public varname as string"). Module level is available to all subs/functions in module and globals are available to any module. This is one way, there are other ways to accomplish it also. Quote
rkmcswain Posted August 21, 2008 Posted August 21, 2008 Of course, you can still use local variables and just pass the first function result to the second function as an argument. ;;; function 1 just sets a string to the var [b]str[/b] (defun fun1 ( / str) (setq str "\nthis is a test string") str ) ;;; function 2 expects an argument and prints it. (defun fun2 (arg) (princ arg) ) ;;; this code just calls function 2 with function 1 as an argument (fun2 (fun1)) ;;; when you are done, [b]str[/b] is either ;;; nil or it's previous value before running ;;; any of this code. Quote
comcu Posted August 21, 2008 Author Posted August 21, 2008 hi, i am using Vb and have tried putting the following at then top of the module in the General / Declarations sections Public MyAttTextStr As String[/code[ but looking in the local window it does not show the string at all? if i put it at the top of the module with the other Dims then it works for that module? cheers, col Quote
comcu Posted August 21, 2008 Author Posted August 21, 2008 sorry, actually it does work!! many thanks! col Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.