AppleScript vs VBScript

2016-02-03 Thread Kay C Lan
Took up Ali's invitation to give amending the LC Dictionary via GitHub a go.

With regard to - do  as 

The OS X explanation of 'the result' is quite straight forward and easy to
demonstrate.

On OS X systems any result returned by the script language is placed in the
> result.


do "6 / 2" as AppleScript
put "Good Result: " & the result & cr into msg
do "6 / 0" as AppleScript
put "Error Result: " & the result after msg
--produces in the msg box
Good Result: 3.0
Error Result: execution error

I know very little about Windows but the Dictionary entry is quite
confusing:

On Windows systems, the result function will return the value of the global
> variable called "result" in the script that was executed (or empty if no
> such variable was defined)...Any scripts on Windows which contain
> references to WScript will fail to run as WScript objects do not exist in
> the LiveCode Environment. Return values should therefore be placed within
> the global result variable instead of using WScript.Echo.


Searching the List for VBScript examples I see nowhere where a global
'result' variable is defined but a simple test if LC's 'the result'
contains "error". For WScript examples I can't find anything that seems to
return anything, they all seem to just do something and in most cases seem
to be offered as an solution outside of LC. Also, why use the 'global
result' instead of WScript.Echo if do  as WScript wont run at
all in LC?

I would appreciate if someone could provide a basic VBScript example like
the AppleScript one above, that demonstrates both valid and error returns.

ALSO, if someone could please decipher what is written about Windows and
tell me what it means in plain English. I get the impression that VBScript
behaves like AppleScript. For WScript I get the impression that it's
talking about a completely different scenario - WScript is being run
outside of LC and you are interested in checking on it's progress. This
doesn't seem to related to: do  as 
and probably belongs elsewhere.

Thanks.
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: AppleScript vs VBScript

2016-02-03 Thread Trevor DeVore
On Wed, Feb 3, 2016 at 10:25 AM, Kay C Lan  wrote:

>
> I see in the last script how you've declared  in VBScript, but I
> believe this below script is also your script and  is not declared,
> you simple check LC's own 'the result'.
>
> (line wraps are probably all over the place)
>
> ##
> put the uActiveServerLoginVBScript of me into theScript
>

The actual script is in uActiveServerLoginVBScript. Does that not have
 declared in it anywhere? That is my code but I haven't looked at
it in a long time.

-- 
Trevor DeVore
ScreenSteps
www.screensteps.com-www.clarify-it.com
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: AppleScript vs VBScript

2016-02-03 Thread Trevor DeVore
On Wed, Feb 3, 2016 at 5:08 AM, Kay C Lan  wrote:

>
> Searching the List for VBScript examples I see nowhere where a global
> 'result' variable is defined but a simple test if LC's 'the result'
> contains "error".
>

Here is a VBScript I have used in the past that sets the  so that
the value is returned to LiveCode.

==
dim theSubError
dim theProcesses

On Error Resume Next

'grabs the full process list and puts it in a var
if Err.Number = 0 then
set objService = getobject("winmgmts:")
for each Process in objService.InstancesOf("Win32_process")
theProcesses = theProcesses & Process.Name & vbLf
Next
end if


if Err.Number <> 0 then
result = Err.Number & ": " & Err.Description
else
result = theProcesses
end if
==

-- 
Trevor DeVore
ScreenSteps
www.screensteps.com-www.clarify-it.com
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: AppleScript vs VBScript

2016-02-03 Thread Kay C Lan
Ah, just the person I was hoping would answer.

I see in the last script how you've declared  in VBScript, but I
believe this below script is also your script and  is not declared,
you simple check LC's own 'the result'.

(line wraps are probably all over the place)

##
put the uActiveServerLoginVBScript of me into theScript
replace "[[Domain]]" with theConfigA["settings"]["credential provider
domain"] in theScript -- "directory.something.corp:389"
replace "[[Query]]" with theConfigA["settings"]["credential provider
query"] in theScript -- "ou=Users,dc=something,dc=corp"
replace "[[Username]]" with pProjectA["credentials"]["login"] in theScript
replace "[[Password]]" with
wgdb_decryptString(pProjectA["credentials"]["password"]) in theScript
replace "[[UserKey]]" with theConfigA["settings"]["credential provider user
query key"] in theScript
do theScript as "vbscript"
if the result begins with "error," then put item 2 to -1 of the result into
theError
else
put the result into theADUserInfo ## last name, first name & cr & group &
tab & group ...
-- CN=,OU=Groups,DC=,DC=corp
end if
##

So again this leave me wonder as to the real situation with Windows? Can it
be like OS X where you simply check LC's 'the result' ? On Windows how do
you know when you NEED to declare  in VBScript and when you don't ?
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: AppleScript vs VBScript

2016-02-03 Thread Kay C Lan
Thanks Mark, that is certainly much clearer than what the Dictionary says.

I've found this nice short example on the List but before I add it to the
Dictionary I would appreciate if someone could confirm it works in the
latest version of Windows. The poster made a snide comment that it may or
may not work with certain flavours of VBScript & Windows:


   put "result = FormatCurrency(25432)" into tScript
   do tScript as vbscript
   put the result


As long as your system region settings are what you expect you should get
$25,432.00 in the message box

On Thu, Feb 4, 2016 at 12:59 AM, Mark Waddingham  wrote:

> On 2016-02-03 16:25, Kay C Lan wrote:
>
>> So again this leave me wonder as to the real situation with Windows? Can
>> it
>> be like OS X where you simply check LC's 'the result' ? On Windows how do
>> you know when you NEED to declare  in VBScript and when you don't
>> ?
>>
>
> My AppleScript and VBScript are a little rusty, however if I recall
> correctly...
>
> All statements in AppleScript notionally return a value (just like
> JavaScript). This means that if you execute a snippet of AppleScript, there
> is a well-defined 'result' which can be returned. So all the engine does
> for AppleScript is use the returned value from the 'exec code snippet' API
> that is used to set 'the result' on the LiveCode side.
>
> In contrast, no statements in VBScript return a value - only expressions
> do. This means that when you execute a snippet of VBScript there is no
> return value to be had from the API which is used. To work-around this the
> engine does the following:
>   1) execute snippet of VBScript
>   2) if the script has declared a global 'result' variable, take the value
> of that and set 'the result' on the LiveCode side
>   3) if the script has not declared a global 'result' variable, then set
> 'the result' to empty on the LiveCode side
>
> Therefore, in answer to your question, if you want your VBScript code
> snippet to return a value to LiveCode when using 'do ... as ...', you have
> to declare a global variable called 'result' in the snippet and set that to
> the return value you want LiveCode to see (in that snippet).
>
> Hope this helps!
>
> Mark.
>
> --
> Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
> LiveCode: Everyone can create apps
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: AppleScript vs VBScript

2016-02-03 Thread Mark Waddingham

On 2016-02-03 16:25, Kay C Lan wrote:
So again this leave me wonder as to the real situation with Windows? 
Can it
be like OS X where you simply check LC's 'the result' ? On Windows how 
do
you know when you NEED to declare  in VBScript and when you 
don't ?


My AppleScript and VBScript are a little rusty, however if I recall 
correctly...


All statements in AppleScript notionally return a value (just like 
JavaScript). This means that if you execute a snippet of AppleScript, 
there is a well-defined 'result' which can be returned. So all the 
engine does for AppleScript is use the returned value from the 'exec 
code snippet' API that is used to set 'the result' on the LiveCode side.


In contrast, no statements in VBScript return a value - only expressions 
do. This means that when you execute a snippet of VBScript there is no 
return value to be had from the API which is used. To work-around this 
the engine does the following:

  1) execute snippet of VBScript
  2) if the script has declared a global 'result' variable, take the 
value of that and set 'the result' on the LiveCode side
  3) if the script has not declared a global 'result' variable, then set 
'the result' to empty on the LiveCode side


Therefore, in answer to your question, if you want your VBScript code 
snippet to return a value to LiveCode when using 'do ... as ...', you 
have to declare a global variable called 'result' in the snippet and set 
that to the return value you want LiveCode to see (in that snippet).


Hope this helps!

Mark.

--
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode