Page 1 of 1 1
Topic Options
#39576 - 2003-04-28 03:50 PM reload a kixscript
guenti Offline
Fresh Scripter

Registered: 2000-09-29
Posts: 26
Loc: Switzerland
is there a way to reload a kix-script? in my script i map some networkdrives and some netprinters and after this i start a userform to show all connections. all this is in the header of the script (no functions). the user can take some changes and press an update-button to change the connections. the easyest way to make the changes is to reload the kix.script.
i try it with
----quit
----Shell "kix32.exe login.kix"
but the "old userform is still in the backgruond..

is there a way to do this?

thanks
guenti

Top
#39577 - 2003-04-28 04:00 PM Re: reload a kixscript
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you want to also re-load the form?
_________________________
!

download KiXnet

Top
#39578 - 2003-04-28 04:03 PM Re: reload a kixscript
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Please read ABC's of KiXtart board etiquette and message to new forum users Section F and repost your question.

Also, specify what this form is that you are talking about and include your code.
_________________________
There are two types of vessels, submarines and targets.

Top
#39579 - 2003-04-28 04:37 PM Re: reload a kixscript
guenti Offline
Fresh Scripter

Registered: 2000-09-29
Posts: 26
Loc: Switzerland
so this is my code...sorry
i have an update-button to reload the script because it is possible to change the content of the $Studprintfile by using the printer button if the user needs other printers....
special lines in script are marked with some ####

code:
 SetConsole("hide")


;********************************************************************
;Systemvariablen
;********************************************************************
########################from here i need to reload
;IP Adress Server
$ipserver = "10.13.48.16"
;IP Adress Printserver
$ipprintserver = "10.13.48.21"
;Anzahl Drucker
$anzahlprinter = 30
;Anzahl Druckerverbindungen
$anzahlprinterconnection=0
;Name des Standartdruckers
$defprintername=" "
;Pfad für delprinter.txt Datei
$delprintfile = "\\" + $ipserver + "\netlogon\delprinter.txt"
;Pfad für Studentenprinter.txt Datei
$Studprintfile = "\\" + $ipserver + "\netlogon\studentenprinter.txt"


If (InGroup ("AngestellteM") OR InGroup("AngestellteLABOR"))
$benutzer="Angestellte_M$$"
EndIf
If (InGroup ("StudentenM"))
$benutzer="Studenten_M$$"
EndIf
If (InGroup ("StudentenC"))
$benutzer="Studenten_C$$"
EndIf

;Pfad für Printer.txt Datei
$Printfile ="\\" + $ipserver + "\" + $benutzer + "\" + "@userid" + "\admin\printer.txt"
;Use x: "\\" + $ipserver + "\angestellte_m$$"

;********************************************************************
;Kontrolle ob der PDC-Server vorhanden ist
;********************************************************************
If Exist ("\\" + $ipserver + "\netlogon\exist.txt")
;MessageBox("Alles i.O","",0)
Else
MessageBox (" Achtung der Hauptserver ist ausgefallen,
Bitte speichern Sie ihre Daten nur auf der Festplatte
C:\.Daten welche auf dem Server gespeichert werden,
gehen verlohren.", "---> Error auf dem Hauptserver <---",048)
EndIf

;********************************************************************
;Löschen aller Druckerverbindungen
;********************************************************************
Shell "con2prt.exe /f"

;********************************************************************
;Verbinden der Drucker
;********************************************************************

If InGroup ("Studenten")
MessageBox("Student"," ",0)
;Alle Drucker für die Studenten
;MessageBox ($studprintfile,"test",0)
Open (1,$Studprintfile,3)
For $i = 1 to $anzahlprinter
$x=ReadLine(1)

$verbinden=SubStr($x,Len($x)-2,1)

If $verbinden = 1
$printername=SubStr($x,1,Len($x)-4)
;MessageBox ("\\" + $ipprintserver + "\" + $printername,"tt",0)
If AddPrinterConnection ("\\" + $ipprintserver + "\" + $printername) = 0
? "Added printer connection"
;$defaultprinter=Right($x,1)
; MessageBox ($defaultprinter,"defaultprinter",36)
; If $defaultprinter = 1
; $defprinter = Left($printername,Len($printername)-1)
; If SetDefaultPrinter ("\\" + $ipprintserver + "\" + $defprinter) = 0
; ? "Defaultprinter set"
; EndIf
; EndIf
EndIf
Else
EndIf
Next
Close (1)
;*******************************************
;Standartdruckerzuweisung für Schulungsräume
;*******************************************

;Schulungsraum S15
If InStr(@WKSTA,"bmasc2")
$defprinter="Laserjet_5000_s15"
If SetDefaultPrinter ("\\" + $ipprintserver + "\" + $defprinter) = 0
? "Defaultprinter set"
EndIf
EndIf

;Schulungsraum S16
If InStr(@WKSTA,"bmasc3")
$defprinter="Laserjet_5000_s15"
If SetDefaultPrinter ("\\" + $ipprintserver + "\" + $defprinter) = 0
? "Defaultprinter set"
EndIf
EndIf

;Schulungsraum S17
If InStr(@WKSTA,"bmasc4")
$defprinter="Colorjet_4500sw_s17"
If SetDefaultPrinter ("\\" + $ipprintserver + "\" + $defprinter) = 0
? "Defaultprinter set"
EndIf
EndIf

EndIf



;********************************************************************
;Löschen der Netzlaufwerke
;********************************************************************

;Löscht das Publiclaufwerk
Use p: /delete

;Löscht das Industrielaufwerkes
Use i: /delete

;Löscht das CAD-Laufwerk
Use l: /delete

;Löscht das Daten_M-Laufwerk
Use m: /delete

;Löscht das Komischen-Laufwerk
Use z: /delete

;Löscht das persönliche Laufwerk
Use u: /delete

; MessageBox ("169", "", 0)


;********************************************************************
;Verbinden der Netzlaufwerke
;********************************************************************

;Verbindet das Publiclaufwerk
If (InGroup ("AngestellteM") OR InGroup("AngestellteLABOR"))
Use p: "\\" + $ipserver + "\public$$"
Else
Use p: "\\" + $ipserver + "\public$$\studenten_m"
EndIf

;Verbinden des Industrielaufwerkes
If (InGroup ("Angestellte"))
Use i: "\\" + $ipserver + "\industrie$$"
EndIf

;Verbinden vom CAD-Laufwerk
If (InGroup ("AngestellteCAD"))
Use l: "\\cads1001\daten_cad$$"
EndIf

;Verbinden vom Daten_M-Laufwerk
If (InGroup ("AngestellteLABOR") OR InGroup("AngestellteM"))
Use m: "\\" + $ipserver + "\daten_m$$"
EndIf

;Verbinden vom Komischen-Laufwerk
If (InGroup ("Komisches"))
Use z: "\\cads1001\spielwiese$$"
EndIf


If Exist("\\" + $ipserver + "\" + $benutzer + "\" + "@userid" + "\admin\info.exe")
Else
Shell "cmd /c mkdir \\MASS1001\$benutzer\%username%\admin"
Shell "cmd /c copy \\MASS1001\netlogon\chemie\admin\info.exe \\MASS1001\$benutzer\%username%\admin"
Shell "cmd /c echo y| cacls \\MASS1001\$benutzer\%username% /g %username%:c"
EndIf

;Shell "cmd /c copy \\MASS1001\netlogon\ideas_ms9\mplot.set d:\mquest2000\custom\mplot2k"


Use u: "\\" + $ipserver + "\" + $benutzer + "\" + "@userid"
##########################to here
Break On
;**************************************************
;Layoutvorlage
;**************************************************

$Form = CreateObject("Kixtart.Form")
$xform=400
$yform=400
$Form.Show
$Form.Caption = "Loginscript CAD-Zentrum"
$Form.Width = $xform
$Form.Height = $yform
$Form.Center
$Form.Backcolor = 82,136,191
$Form.Show
$form.forecolor = 255,255,255
$form.drawwidth = 3
;Vertikale Linien
$form.line (80,8,80,70)
$form.line (80,89,80,$yform-35)
;Horizontale Linien
$form.line (8,80,70,80)
$form.line (90,80,$xform-16,80)
$form.circle (80,80,10)

$Image = $form.Image("\\" + $ipserver + "\netlogon\industrie_blau.bmp",82,7)
$Image.Fontsize =0
$Image.Border = 0
$Image.show
$Form.Show
$Image1 = $form.Image("\\" + $ipserver + "\netlogon\it.bmp",68,$yform-110 )
$Image1.Fontsize =0
$Image1.Border = 0
$Image1.show
$Form.Show

$fraDetails = $FORM.Frame("User-Info")
$fraDetails.FontSize = 14
$fraDetails.HEIGHT = $yform-195
$fraDetails.Left = 90
$fraDetails.TOP = 85
$fraDetails.WIDTH = $xform-105
$Form.Show

$cbupdate=$form.commandbutton("Update",$xform-95-200,$yform-80,80)
$cbprint = $form.commandbutton("Printer",$xform-95-100,$yform-80,80)
;$cbgo.enabled=0
$cbende=$form.commandbutton("Quit",$xform-95,$yform-80,80)

$cbprint.onclick = "drucken"

$cbupdate.onclick = "progstart"
################ my update-button

$cbende.onclick = "filebeenden"
;





$xtab=100
$Tab=160
$Form.FontSize = 11
$Form.ForeColor = 0,0,0; Black
$Form.PrintXY($xtab,120, "Benutzername:")
$Form.PrintXY($xtab+$tab,120, @userid )
$Form.PrintXY($xtab,140, "Vollständiger Name:")
$Form.PrintXY($xtab+$tab,140, @fullname )
$Form.PrintXY($xtab,160, "Loginserver:")
$Form.PrintXY($xtab+$tab,160, @lserver )
$Form.PrintXY($xtab,180, "Computername:")
$Form.PrintXY($xtab+$tab,180, @wksta )
$Form.PrintXY($xtab,200, "Passwortalter (Tage):")
$Form.PrintXY($xtab+$tab,200, @pwage )
$Form.PrintXY($xtab,220, "Anzahl Netzwerkdrucker:")
$Form.PrintXY($xtab+$tab,220, $anzahlprinterconnection)
$Form.PrintXY($xtab,240, "Standarddrucker:")
$Form.PrintXY($tab,260, $defprintername )



;**************************************************



$Form.Show
While $Form.Visible
$=Execute($Form.DoEvents())
Loop

Exit 1


Function progstart
###############here is my problem ???????
EndFunction


Function drucken

Shell "\\10.1.48.16\netlogon\wkix32.exe \\10.1.48.16\netlogon\printer.kix"
; Quit
EndFunction



Function filebeenden
Quit
EndFunction


Top
#39580 - 2003-04-28 04:41 PM Re: reload a kixscript
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
heh...
simpliest way is to use goto.
but I'm still not sure is that what you want.

to reload all the mappings and the form and all just because user presses a button.

you might want to add some wisdow to the logic.
all you need is to carry out the change and update the form!

you can always point it to goto line1 but then your users will be mad.
_________________________
!

download KiXnet

Top
#39581 - 2003-04-29 08:09 AM Re: reload a kixscript
guenti Offline
Fresh Scripter

Registered: 2000-09-29
Posts: 26
Loc: Switzerland
hello
its not so easy with a simply goto. i try it but i think the problem is goto from a function. here a small version with goto and a function it doesn't run:
code:
 
:start
$x=MessageBox ("it runs", "update" ,52)
If $x = 6
test
Else
Quit
EndIf

Function test
Goto "start"
endfunction

this way it runs without any problems
code:
 :start
$end = "start"
$x=MessageBox ("hallo", "velo" ,52)
If $x = 6
Goto "start"
Else
Quit
EndIf

and i think there should be an other way without goto (i don't like it, it is to basic ;o) )
but if it runs with a function then i will take it ;o)
thanks guenti

Top
#39582 - 2003-04-29 08:24 AM Re: reload a kixscript
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Not sure it is valid to use a GOTO from within a Function

Returned error is 6 The handle is invalid.
ERROR : LABEL [start] not found!
Script: C:\temp\test.kix
Line : 14



; test.kix

;:start
$x=MessageBox ("it runs", "update" ,52)
If $x = 6
  ? 'Returned error is '+@ERROR +'  '+@SERROR
  test
Else
  ? 'var did not equal 6 - Returned error is '+@ERROR +'  '+@SERROR
  Quit
EndIf

Function test
  Goto "start"
endfunction

GOTO END
:start
? 'Hi start test'

:END


Top
#39583 - 2003-04-29 08:51 AM Re: reload a kixscript
guenti Offline
Fresh Scripter

Registered: 2000-09-29
Posts: 26
Loc: Switzerland
this code doesn't run. error on line 17; label not found...

guenti

Top
#39584 - 2003-04-29 09:30 AM Re: reload a kixscript
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Correct guenti

That is what I said. I tried to modify your code with return error codes and based on that, I don't think the GOTO is supported from within a Function.

I could be wrong, but it doesn't run as you've seen.

I think you need to modify your code to use other methods.

Top
#39585 - 2003-04-29 11:34 AM Re: reload a kixscript
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hehee.
I said that it would be easiest but would mess a lot.
_________________________
!

download KiXnet

Top
#39586 - 2003-04-29 01:41 PM Re: reload a kixscript
guenti Offline
Fresh Scripter

Registered: 2000-09-29
Posts: 26
Loc: Switzerland
hey again ;o)
so now i find a solution for my first problem without goto..... i put all about printers in a function and it runs not bad ;o)
but no my userform shows not the actual text...
here a small prog:
code:
 
$Form = CreateObject("Kixtart.Form")
$form.visible = 0
$xform=400
$yform=400
$Form.Show
$Form.Caption = "Loginscript CAD-Zentrum"
$Form.Width = $xform
$Form.Height = $yform
$Form.Center
$Form.Backcolor = 82,136,191
$Form.Show
$form.forecolor = 255,255,255
$form.drawwidth = 3
;Vertikale Linien
$form.line (80,8,80,70)
$form.line (80,89,80,$yform-35)
;Horizontale Linien
$form.line (8,80,70,80)
$form.line (90,80,$xform-16,80)
$form.circle (80,80,10)



;$cbgo.enabled=0
$cbende=$form.commandbutton("test",$xform-95,$yform-80,80)
$cbende.onclick = "test"

$xtab=100
$Tab=160
$Form.FontSize = 11
$Form.ForeColor = 0,0,0; Black
$Form.PrintXY($xtab,120, "Benutzername:")
$Form.PrintXY($xtab+$tab,120, @userid )
$Form.PrintXY($xtab,140, "Vollständiger Name:")
$Form.PrintXY($xtab+$tab,140, @fullname )
$Form.PrintXY($xtab,160, "Loginserver:")
$Form.PrintXY($xtab+$tab,160, @lserver )
$Form.PrintXY($xtab,180, "Computername:")
$Form.PrintXY($xtab+$tab,180, @wksta )
$Form.PrintXY($xtab,200, "Passwortalter (Tage):")
$Form.PrintXY($xtab+$tab,200, @pwage )
$Form.PrintXY($xtab,220, "Anzahl Netzwerkdrucker:")
$Form.PrintXY($xtab+$tab,220, $anzahlprinterconnection)
$Form.PrintXY($xtab,240, "Standarddrucker:")
$Form.PrintXY($tab,260, $defprintername )
;**************************************************
While $Form.Visible
$=Execute($Form.DoEvents())
Loop
Exit 1

Function test
$anzahlprinterconnection = 1
$defprintername = "Testprinter"
EndFunction

if i click on the button then set the two variables, after that i want to show the changed text in my userform...
any idea

guenti

Top
#39587 - 2003-04-29 01:51 PM Re: reload a kixscript
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you could do it without printxy (with label or so to save you some strokes.

with printxy you can do it like:
code:
Function test
$anzahlprinterconnection = 1
$Form.forecolor=$form.backcolor
$Form.PrintXY($tab,260, $defprintername )
$defprintername = "Testprinter"
$Form.forecolor=black
$Form.PrintXY($tab,260, $defprintername )
EndFunction

you must remember, that printxy is not object but just a form painter.
it paints something on the background and thus it's usage is little tricky.

[ 29. April 2003, 13:51: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#39588 - 2003-04-29 03:28 PM Re: reload a kixscript
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
First of all, it would be better to use the LABEL object instead of the PRINTXY object, as it results in a cleaner KiXForms setup.

Secondly, once you've got the labels set up, you just assign a new text to the label and it will be reflected.

Thirdly, I would create the form first, then process the other tasks, and provide feedback to some kind of update label object.

Lastly, don't use GOTO's anywhere, they're just trouble.
_________________________
There are two types of vessels, submarines and targets.

Top
#39589 - 2003-04-29 03:32 PM Re: reload a kixscript
guenti Offline
Fresh Scripter

Registered: 2000-09-29
Posts: 26
Loc: Switzerland
hey, cool

i change printxy with label's and now everything works graet [Wink]
thanks for your help

guenti

i've got more special questions, but later [Wink]

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2375 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.126 seconds in which 0.067 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