Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: vbscript - global / X10 Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
phil13
Groupie
Groupie
Avatar

Joined: December 19 2004
Location: France
Online Status: Offline
Posts: 60
Posted: April 19 2005 at 14:35 | IP Logged Quote phil13

Hi dave,

i've a little problem to make working a little vbscript.

Can you tell me where is the problem ?

i launch the script with the powerhome script editor with 2 parameters "off", 1

The first time i execute the script after to have reinitialized powerhome, i've an unexpected error on line 11 (the first ph.X10).

Then after, each time i execute it, i've an unexpected error on line 5 (not the same line ...).

sub cmd_filtration (cmde, manuel)

dim tempo_dem, tempo_auj, tempo_hchp, retour

tempo_dem=ph.getglobal_s ( "TEMPO DEMAIN" )
tempo_auj=ph.getglobal_s ( "TEMPO AUJOURDHUI" )
tempo_hchp=ph.getglobal_s ( "TEMPO HCHP" )

if cmde="off" then
     retour=ph.setglobal_n ("TIMER FILTRATION" , 0)
     retour=ph.x10btn ( "H", 1, 2, 0 )
end if

if cmde="on" then
     retour=ph.setglobal_n ("TIMER FILTRATION" ,60)
     retour=ph.x10btn ( "H", 1, 3, 0 )
end if

end sub

tempo_dem, tempo_auj, tempo_hchp are not still used.

Philippe
Back to Top View phil13's Profile Search for other posts by phil13
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: April 19 2005 at 15:47 | IP Logged Quote dhoward

Philippe,

It's my problem . Apparently when I changed the definition of the ph_x10btn function to take an integer as the level, I failed to update the ph.x10btn script function and it was trying to feed a string to an integer field.

Anyways...you can download a fixed phscr.pbd file from here: http://www.power-home.com/download/phscr.zip.

Shutdown PowerHome and then unzip the above file and overwrite the one in your PowerHome directory. Restart PowerHome and the ph.x10btn function should work as expected.

Let me know if you have any other problems,

Dave.


Edited by dhoward
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
phil13
Groupie
Groupie
Avatar

Joined: December 19 2004
Location: France
Online Status: Offline
Posts: 60
Posted: April 20 2005 at 09:30 | IP Logged Quote phil13

OK for ph_x10btn with the patch.

Otherwise, i've another similar problem :

it's seems that code doesn't works :
dim duree
duree=40
retour=ph.setglobal_n ("TIMER FILTRATION" , duree)
The value in "TIMER FILTRATION" is false.

But this code works :
retour=ph.setglobal_n ("TIMER FILTRATION" , 40)

In fact, i need to put a calculate value in a global variable.
How do i have to proceed ?

Thanks

Philippe
Back to Top View phil13's Profile Search for other posts by phil13
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: April 20 2005 at 13:34 | IP Logged Quote dhoward

Phillipe,

I tested this and got errors as well. I didnt get "false" but some equally bizarre number. Ive combed the code several times as well inquiries on the net and the best Ive been able to determine is that when the variable is passed from vbscript to PowerBuilder, it's not able to properly reference the actual variable value. When a numeric literal is passed (the 40 in your working code), it doesn't have a problem. But it's unable to interpret a numeric variable (string variables seem to work fine).

Anyways...the workaround is simple enough. We just need to make the variable look like a literal value and then it'll work fine.

Change your line:

retour = ph.setglobal_n("TIMER FILTRATION",duree)

To:

retour = ph.setglobal_n("TIMER FILTRATION",cint(duree))

The "cint" function effectively removes the variable reference. You can also use "cdbl" and then be able to pass integers as well as doubles.

Not many people use the scripting capabilities of PowerHome so I appreciate your efforts in testing.

Let me know how it goes and if you have any other problems.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum