Sub routine now working

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Sub routine now working

Post by gchichester » Wed Sep 29, 2010 7:41 pm

Yes it's me again and I still trying to learn how to work with the new
dialog options. I can't figure out why the "Let>varLoadPort..." command
will not return any values.
I've verified the %LPort% is getting the correct value.
But the varLoadPort message just returns %varLoadPort%
I tried moving the AddDialogHandler command, that did't help either.

[code]
BolDialog code
.....
AddDialogHandler>BoLDialog,DischargePort,OnExit,subLoadPort
Show>BoLDialog,r

SRT>subLoadPort
GetDialogProperty>BolDialog,LoadPort,Text,LPort

If %LPort% = "CHARLESTON, SC"
Let>varLoadPort = 1601
EndIf

Else

If %LPort% = "JACKSONVILLE, FL"
Let>varLoadPort = 1803
EndIf

Else

If %LPort% = "MIAMI, FL"
Let>varLoadPort = 5201
EndIf

Else

If %LPort% = "SAVANNAH, GA"
Let>varLoadPort = 1703
EndIf

Wait>2
Message>%LPort%
Wait>2
Message>%varLoadPort%

END>subLoadPort
[/code]

Thanks for any and all suggestions
Gil

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Sep 29, 2010 7:50 pm

Remove the spaces. Or use IGNORESPACES. Look up the IGNORESPACES help file topic for an explanation.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Sep 29, 2010 9:17 pm

ALSO

Make sure you have a "greater than symbol" > following any and all Macro Scheduler functions.

Without the ">" after "If" the "If" line will be ignored as if it were a remark and the lines inside the If/EndIf block will always be resolved. That means in your posted code, the variable "varLoadPort" will always equal 1703


In other words:

If %LPort% = "CHARLESTON, SC"
Let>varLoadPort = 1601
EndIf


Will become:

If>%LPort%="CHARLESTON, SC"
Let>varLoadPort=1601
EndIf



Additionally, as your code is written, you also do not need any of the "Else" lines. All of your "Else" lines can be deleted. Look up help for "If'.

gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Sub routine now working

Post by gchichester » Thu Sep 30, 2010 12:09 am

[quote]Remove the spaces. Or use IGNORESPACES. Look up the IGNORESPACES help file topic for an explanation.[/quote]
Yes, I have the system variable Let>IGNORESPACES=1 set at the beginning of my script. I learned about that one the hard way. Thanks

[quote]Make sure you have a "greater than symbol" > following any and all Macro Scheduler functions. [/quote]
I really feel dumb for not seeing that I was missing the > symbol! in my code.
I guess I got it confused with some vba coding I'm doing or at least thats my excuse and I'm sticking with it.

Thanks for pointing it out.

Gil

gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Sub routine now working

Post by gchichester » Thu Sep 30, 2010 12:32 pm

Ok I cleaned up my code making sure there are no spaces along with the system variable
Let>IGNORESPACES=1.
When subLoadPort is called The LPort variable continues to return the correct value.
I confirmed this with the message command. But now the varLoadPort only returns
the 1703 value no matter which LPort I choose. Again confirmed with a message command.
What could cause the if statement to fail, knowing that the variable has the correct value?

Code: Select all

SRT>subLoadPort
GetDialogProperty>BolDialog,LoadPort,Text,LPort

 If>%LPort%="CHARLESTON, SC"
 Let>varLoadPort=1601
 EndIf

 If>%LPort%="JACKSONVILLE, FL"
 Let>varLoadPort=1803
 EndIf

 If>%LPort%="MIAMI, FL"
 Let>varLoadPort=5201
 EndIf

 If>%LPort%="SAVANNAH, GA"
 Let>varLoadPort=1703
 EndIf

Wait>2
Message>%LPort%
Wait>2
Message>%varLoadPort%
END>subLoadPort
As always thanks for you feedback

Gil

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Sep 30, 2010 12:48 pm

I think you want:

Code: Select all

 If>LPort={"CHARLESTON, SC"}
   Let>varLoadPort=1601
 EndIf

 If>LPort={"JACKSONVILLE, FL"}
   Let>varLoadPort=1803
 EndIf

 If>LPort={"MIAMI, FL"}
   Let>varLoadPort=5201
 EndIf

 If>LPort={"SAVANNAH, GA"}
   Let>varLoadPort=1703
 EndIf
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Sub routine now working

Post by gchichester » Thu Sep 30, 2010 1:28 pm

That did the trick!

Thanks again Marcus


Gil

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts