Page 2 of 2 <12
Topic Options
#205280 - 2012-05-18 08:01 PM Re: AddPrinterConnection -> does not work sometimes [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Or if you dont want to set the novars and nomacros options to ON, this also seems to return the correct error.

 Code:
? tryCommand("use c: '\\fileserver\share1'", 3)
? tryCommand("use c: '\\fileserver\share1'", 3)
? tryCommand("use c: '\\fileserver\share1'", 3)
get $

function tryCommand($command, $howoften, OPTIONAL $interval)
   DIM $i
   DIM $ERROR
   $i = 0
   if $howoften < 1 
      $tryCommand = -1
      return $tryCommand
   endif
   do
      $ = execute($command+" $$ERROR = @@error")
      if $ERROR = 0 
         $tryCommand = $ERROR
         return $ERROR
      endif
      if $interval <> ""
         sleep $interval
      endif
      $i = $i + 1
   until $i = $howoften
   $tryCommand = $ERROR
endfunction

Top
#205282 - 2012-05-18 09:52 PM Re: AddPrinterConnection -> does not work sometimes [Re: ShaneEP]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
indeed, just like I posted ;\)

Les, yea, him it indeed was. seemed to LOOVE execute-statements back in the day.
_________________________
!

download KiXnet

Top
#205283 - 2012-05-21 09:39 AM Re: AddPrinterConnection -> does not work sometimes [Re: Lonkero]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
it was me, yeah,

since this time we do things in kixforms like this:

 Code:
while $f.Visible
	$ = execute($f.DoEvents)
loop
_________________________



Top
#205284 - 2012-05-21 12:43 PM Re: AddPrinterConnection -> does not work sometimes [Re: ShaneEP]
MartinAD Offline
Fresh Scripter

Registered: 2011-08-01
Posts: 13
Loc: -
 Originally Posted By: ShaneEP
Or if you dont want to set the novars and nomacros options to ON, this also seems to return the correct error.

 Code:
? tryCommand("use c: '\\fileserver\share1'", 3)
? tryCommand("use c: '\\fileserver\share1'", 3)
? tryCommand("use c: '\\fileserver\share1'", 3)
get $

function tryCommand($command, $howoften, OPTIONAL $interval)
   DIM $i
   DIM $ERROR
   $i = 0
   if $howoften < 1 
      $tryCommand = -1
      return $tryCommand
   endif
   do
      $ = execute($command+" $$ERROR = @@error")
      if $ERROR = 0 
         $tryCommand = $ERROR
         return $ERROR
      endif
      if $interval <> ""
         sleep $interval
      endif
      $i = $i + 1
   until $i = $howoften
   $tryCommand = $ERROR
endfunction


thanks for sharing this with me! This works great! I didn't necessarily wanted to change the kix options, since this script-snippet of course is just a small segment in the greater scheme of things.

Now I get proper return codes and will probably be able to find the root of the problem.

Thanks again to everybody for your help and sharing your thoughts and ideas with me.

Top
Page 2 of 2 <12


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (mole) and 494 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.052 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org