Post new topic Reply to topic  [ 6 posts ] 

Board index : TeleFlow Forums : TeleFlow Designer & Simulator

Author Message
 Post subject: Help With Global Variables
PostPosted: Mon Feb 11, 2008 5:05 pm 
Offline

Joined: Tue Feb 05, 2008 3:31 pm
Posts: 8
Hi all,

I am in the midle of a project and, for some reason, when I set what I believe to be, a global variable in a "Sub Routine" it does not save the new value.

Here is a psudo flowchart for ya:
Code:
/////////////////////////////////////////////
//M AI N
/////////////////////////////////////////////
---------[Main]

                 |
                 [@var = 0]

                 |
                 [Sub_Routine_1]

                              |
                              [@var=2]

//////////////////////////////////////////////
//O U T P U T
//////////////////////////////////////////////

@var = 0

Any help is much appreciated.Thanks,

Ben

_________________
Ben Stricklin
Developer
Digtial Systems Support, IT
bstrick338@hotmail.com
:)


Back to top
 Profile YIM 
 
 Post subject:
PostPosted: Tue Feb 12, 2008 12:14 pm 
Offline

Joined: Wed Mar 19, 2003 4:28 pm
Posts: 510
Location: Canada
How are you setting the global in the sub routine? The Set Global and Set Local steps are "sure" ways to set values of local or global variables, respectively.

Note that a local version of a variable always takes precedence.

So, if you have a global variable @MY_VARIABLE, and you have a flowchart that creates a local @MY_VARIABLE with a set local step, any action in that flowchart that sets @MY_VARIABLE, other than the Set Global step, will affect the local variable.

To help keep things simple, avoid having local and global variables with the same name.

Additional notes:
- All variables in TeleFlow are automatically global by default. Only the Set Local step, the LOCAL expression in a Run Basic Script step, or flowchart parameters create local variables.
- Only steps that are passed through in flow actually have any affect. (So, if something can cause the flow to go around or not pass through a Set Global step, for example, the value of the variable might not get updated)


Back to top
 Profile WWW 
 
 Post subject:
PostPosted: Tue Feb 12, 2008 4:43 pm 
Offline

Joined: Tue Feb 05, 2008 3:31 pm
Posts: 8
I have a global variable called @CALL_ID.

I want this to be available from the my Main flowchart to each Sub routine that I call. I also want to be able to update this variable from inside any of the subroutines.

Since I want to loop through a list of users to call, I:


∙ Run an SQL query inside my main function To Get Users' info
∙ Dial A Users' Number
∙ Run A Sub Routine to get user input
∙ Insert a record into a "Calls" table with pertinent call Info
∙ RUN Query to get Newly Created Call Id 'SELECT ID AS "LOCAL_CALL_ID" FROM.......'
∙Update @Call_Id To The Newly created @LOCAL_CALL_ID
∙ Return Back to Main
∙ Run A Sub routine to Validate the users input
∙ Update some data
∙ Return Back to Main
∙ Hang Up
∙ Update Call Record with @CALL_ELAPSE using Current @CALL_ID
∙ Loop To Next Call


The Problem occurs when i try to updae @Call_ID with the SQL Query. How do I update the global variable @CALL_ID inside the Sub Routine?

set Global @CALL_ID = @LOCAL_CALL_ID ?

Stumped.

_________________
Ben Stricklin
Developer
Digtial Systems Support, IT
bstrick338@hotmail.com
:)


Back to top
 Profile YIM 
 
 Post subject:
PostPosted: Tue Feb 12, 2008 6:24 pm 
Offline

Joined: Wed Mar 19, 2003 4:28 pm
Posts: 510
Location: Canada
Here are a couple of ways you can handle this.

To handle it in your query directly, you would make the SQL field alias the same as your global variable name, without the @ symbol.

EG:

SELECT
my_field AS MY_VARIABLE
FROM
table
WHERE
conditions


Assuming there is no local variable called @MY_VARIABLE in that sub flowchart, that will work.

Alternatively, if you use the SQL statement to get the value as another variable, such as

SELECT
my_field AS MY_OTHER_VARIABLE
FROM etc

you can use the Set Global Variable step to set @MY_VARIABLE equal to @MY_OTHER_VARIABLE.

It is important to note, as well, that a SELECT SQL statement must be followed by a related SQL Fetch step to retrieve the first row in the results set. Otherwise, your variable won't be set by the SQL Statement at all.


Back to top
 Profile WWW 
 
 Post subject:
PostPosted: Wed Feb 13, 2008 11:34 am 
Offline

Joined: Tue Feb 05, 2008 3:31 pm
Posts: 8
Chris,

Man do I feel Stoofid!

I did NOT have a FETCH for the SQL that gets the new ID. Thak you for that.

Now I have an additional question. I am not sure if I should post it here or not, but here goes.

Image

As you can see, I have a loop in my Main Flowchart. I have an SQL Statement , an SQL Fetch, some 'Run Flowcharts', and then LOOP back to the FETCH.

After the first call is completed and it loops back I get :

Feb 13 13:22:47.64: [16] SQLFetch
Feb 13 13:22:47.65: ERROR: No SQL statement defined.
Feb 13 13:22:47.65: FATAL

Any suggestions here?

Thanks Again for all your help.

Ben

_________________
Ben Stricklin
Developer
Digtial Systems Support, IT
bstrick338@hotmail.com
:)


Back to top
 Profile YIM 
 
 Post subject:
PostPosted: Wed Feb 13, 2008 3:27 pm 
Offline

Joined: Wed Mar 19, 2003 4:28 pm
Posts: 510
Location: Canada
Happy to help!

That error indicates the SQL Handle of the Fetch is no longer associated with a SQL Statement. Every SQL Statement step you run has a handle number in it, which you must use to associate the statement with other SQL steps, such as a SQL Fetch. Obviously, you have the initial association working, since the Fetch works once.

The handle must have been closed, which can happen in one of two ways:
1) You have a SQL End step with the same handle as the SQL Statement/SQL Fetch steps that only work once.
2) Somewhere in the logic after you fetch the first row, you run another SQL Statement step, maybe to perform an update, for example, and it uses the same handle number as your fetch. TeleFlow automatically closes off a handle if you re-use it.


Back to top
 Profile WWW 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

Board index : TeleFlow Forums : TeleFlow Designer & Simulator


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Style by Midnight Phoenix & N.Design Studio
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.