passing a variable from one task to another

nnCron and nnCron LITE discussion

passing a variable from one task to another

Postby alexanjo » Tue, 22 Nov 2005, 02:23

Forum:

Brand new to nnCron and Forth, both of which are brilliant!

I am not able to pass variable full_screen from task play_at_scheduled_time to the task play_media_file_windows_media_player. These tasks are reproduced below, all of which exist within the same .tab file.

If I do not declare full_screen within play_media_file_windows_media_player, a syntax error is generated. If full_screen is declared within, it is reset to value zero.

How do I pass a variable from one task to another, within the same .tab file?

Jordan

-----


#( close_media_apps
NoActive

Action:

\ close powerpoint
WIN-CLOSE: "screenClass"
WIN-CLOSE: "PP9FrameClass"
PROC-CLOSE: wmplayer.exe
WIN-CLOSE: "Media Player Classic"
WIN-CLOSE: "Winamp v1.x"
)#

#( start_message_board
NoActive
AsLoggedUser

Action:

StartIn: "C:\Program Files\Microsoft Office\Office"
ShowNormal NormalPriority
START-APP: C:\Program Files\Microsoft Office\Office\POWERPNT.EXE /s "C:\Documents and Settings\Administrator\My Documents\seanix_laptop\sjpat\slides\SJPAT19running.ppt"
)#

#( play_media_file_windows_media_player
NoActive
AsLoggedUser
VARIABLE full_screen

Action:

StartIn: "C:\Program Files\Windows Media Player"
ShowNormal NormalPriority
full_screen 1 =
IF ShowMinimized START-APP: C:\Program Files\Windows Media Player\wmplayer.exe "%file_path COUNT%"
ELSE START-APP: C:\Program Files\Windows Media Player\wmplayer.exe "%file_path COUNT%" /fullscreen
THEN
)#

#( play_at_scheduled_time

AsLoggedUser
Time: 52 06 20 11 * 2005
CREATE file_path 256 ALLOT
S" C:\Documents and Settings\Administrator\My Documents\video\ben_white_cobb1.wmv" file_path PLACE
1 VALUE full_screen

Action:

close_media_apps RUN
play_media_file_windows_media_player RUN
PAUSE: 20000
start_message_board RUN
)#
alexanjo
 
Posts: 19
Joined: Tue, 22 Nov 2005, 01:57

Postby LuckMan212 » Tue, 22 Nov 2005, 04:13

i am not sure why, because according to nnCron documentation:

"All variables (VARIABLE, VALUE), constants (CONSTANT) and arrays(CREATE ... ALLOT) are global, they can be seen from other tasks and are shared by all instances of any given task. Therefore, in order to avoid unnecessary confusion, one should take a great care to ensure that all variable names are unique."


but even so, you may try file or registry variables, described in the manual. see example:
Code: Select all
#( test_persistent_var
NoActive
\ creating a file variable and a registry variable
fVAR file_var
regVAR reg_var
Action:
    \ assigning string values to variables
    S" first string" TO file_var
    S" second string" TO reg_var
    \ displaying both variables on screen
    MSG: "There are %file_var% and %reg_var%"
)#
LuckMan212
 
Posts: 133
Joined: Mon, 04 Jul 2005, 11:19

"correctly" passing variables between tasks

Postby alexanjo » Tue, 22 Nov 2005, 12:57

Luckman212, et al.

Thanks for responding to my forum inquiry regarding the passing of variables between tasks

After more trying, it seems that I "found" a way that works! Start by including another task before the other ones, where a variable is created (declared). Then "recreate" the same variable by using the so-called self-fetching variable command to assign it a value in the task that calls another task where it is used...

Here is how it looks:

#( define_variables
NoActive
VARIABLE full_screen
Action:
)#

#( close_media_apps
NoActive
Action:

\ close powerpoint
WIN-CLOSE: "screenClass"
WIN-CLOSE: "PP9FrameClass"
PROC-CLOSE: wmplayer.exe
WIN-CLOSE: "Media Player Classic"
WIN-CLOSE: "Winamp v1.x"
)#

#( start_message_board
NoActive
AsLoggedUser
Action:

StartIn: "C:\Program Files\Microsoft Office\Office11"
ShowNormal NormalPriority
START-APP: C:\Program Files\Microsoft Office\OFFICE11\POWERPNT.EXE /s "D:\jordan\SJPAT\slides\SJPAT19running.ppt"
)#

#( play_media_file_windows_media_player
NoActive
AsLoggedUser
Action:

StartIn: "C:\Program Files\Windows Media Player"
NormalPriority \ ShowNormal
full_screen 1 =
IF
START-APP: C:\Program Files\Windows Media Player\wmplayer.exe "%file_path COUNT%" /fullscreen
ELSE
ShowMinimized
START-APP: C:\Program Files\Windows Media Player\wmplayer.exe "%file_path COUNT%"
THEN
)#

#( play_at_scheduled_time

AsLoggedUser
Time: 37 01 22 11 * 2005

CREATE file_path 256 ALLOT
S" D:\jordan\SJPAT\ideacity-06242005.wmv" file_path PLACE
1 VALUE full_screen
Action:

close_media_apps RUN
play_media_file_windows_media_player RUN
PAUSE: 20000
start_message_board RUN
)#
alexanjo
 
Posts: 19
Joined: Tue, 22 Nov 2005, 01:57

Re: passing a variable from one task to another

Postby VK » Tue, 22 Nov 2005, 13:00

alexanjo wrote:VARIABLE full_screen
1 VALUE full_screen


This is an example of incorrect usage of Variables and Self-fetching Variables (VALUE). You are just creating two different variables with the same name.

Just take a look in nnCron docs for more details: http://www.nncron.ru/help/EN/working/variables.htm
CU
VK
User avatar
VK
 
Posts: 680
Joined: Wed, 14 Jul 2004, 19:17


Return to nnCron forum (English)

Who is online

Users browsing this forum: No registered users and 2 guests

cron