KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Proper method to re-generate an existing form.

 
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic
View previous topic :: View next topic  
Author Message
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Mon Jan 22, 2007 11:27 pm    Post subject: Proper method to re-generate an existing form. Reply with quote

I have a menuing system which works well with the exception of the edit menu information functions. The only way I can properly exit the loop and then regenerate the form to display new or removed buttons is a GOTO !!!
On exiting the Edit Form/Function I leave the main form hidden therefore the primary loop ends and the next command is executed. I have set a global flag to indicate whether to re-generate the form otherwise kix will simply exit. It works up to a fashion but is more of an every other time toggle. Click Edit/Add 1st time - perfect, regenerates, click edit/add again and it does not do the event properly but simply restarts. Third attempt OK...etc.
HOW TO GET RID OF THE GOTO AND GET IT TO EDIT/ADD EVERY TIME ?

i.e.

:START
Read button info from INI file
Build a form....
On event ... Function ADD() or Function Edit() etc...

While $Form1.Visible
$Nul = Execute($Form1.DoEvents())
Loop
If $Flag = "Yes" goto START

Function Edit INI()
$Form1.Hide
... Added or Removed entries therefore need to regenerate new form.
$Flag="Yes"
Endfunction
________
OREGON DISPENSARY


Last edited by MACE1 on Fri Feb 18, 2011 5:06 pm; edited 1 time in total
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Jan 22, 2007 11:47 pm    Post subject: Reply with quote

Can your share the script itself - or at least the relevant parts so that we can actually see what is happening.
_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Tue Jan 23, 2007 2:10 am    Post subject: Reply with quote

the whole script would be best so we can help you trouble shoot the prob.
_________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)
Back to top
View user's profile Send private message Send e-mail
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Tue Jan 23, 2007 9:37 am    Post subject: OK you asked for it...FULL WORKING CODE. Reply with quote

Code:

 ;Quick launch RDP on Windows 2K/XP
 CLS
 BREAK ON
 $os = left(@producttype,10)
 IF $os = "Windows XP" OR $os = "Windows 20"
  :start
  GLOBAL $ini
  GLOBAL $cnt
  GLOBAL $wid
  GLOBAL $restart
  GLOBAL $sarray[99,5]
  $restart=""
  $ini=@scriptdir+"\RDP.ini"
  IF exist($ini)
   ReadINI

   $wy=($cnt*22) + 40
   IF $cnt < 4 $wy = 125
   ENDIF
   $wx=($wid*9)
   IF $wx <100 $wx = 100
   ENDIF

   $system = CreateObject("Kixtart.System")
   $mainform = $system.form()
   $mainform.caption = "RDP profiles [" + $cnt + "]"
   $mainform.width = $wx + 110
   $mainform.height = $wy + 10
   $mainform.topmost = "true"
   $mainform.maximizebox = "false"
   $mainform.minimizebox = "false"
   $mainform.center

   MakeBtns($wx,$wy)

   $sfull = $mainform.controls.radiobutton()
   $sfull.left = $wx + 18
   $sfull.top  = 7
   $sfull.text = "Full Screen"
   $sfull.checked = "False"
   $sfull.height = 24
   $sfull.width = 80
   $sfull.tabstop = "True"

   $swind = $mainform.controls.radiobutton()
   $swind.left = $wx + 18
   $swind.top  = 28
   $swind.text = "Windowed"
   $swind.checked = "True"
   $swind.height = 24
   $swind.width = 80
   $swind.tabstop = "True"

   $adini= $mainform.controls.button()
   $adini.height = 12
   $adini.width = 12
   $adini.left = $wx + 19
   $adini.top = $wy - 70
   $adini.onclick = 'AddINI()'

   $adlab = $mainform.controls.label()
   $adlab.height = 12
   $adlab.width = 60
   $adlab.left = $wx + 36
   $adlab.top = $wy - 70
   $adlab.text = "Add profile"

   $edini= $mainform.controls.checkbox()
   $edini.text = "Edit profile"
   $edini.height = 20
   $edini.width = 80
   $edini.left = $wx + 19
   $edini.top = $wy - 54
   $edini.checkalign = 16
   $edini.checked = "False"

   $mainform.show
   WHILE $mainform.visible
    $=Execute($mainform.doevents())
   LOOP
   IF $restart="Y"
    GOTO START
   ENDIF

  ELSE
   $cnt=0
   AddINI()
   GOTO START
  ENDIF
 ELSE
  MESSAGEBOX ("This requires Windows 2000/XP or newer to run.",@producttype, 0, 0)
 ENDIF

 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION MakeBtns($wx,$wy)

  FOR $x = 1 TO $cnt
   $rdesktop="RDP"+$x
   $bx=($x*22)-15
   execute("$$$RDESKTOP= $$MainForm.Controls.Button()")
   execute("$$$RDESKTOP.text = $$SArray[$$x,0]")
   execute("$$$RDESKTOP.Height = 20")
   execute("$$$RDESKTOP.Width = $$WX")
   execute("$$$RDESKTOP.Left = 8")
   execute("$$$RDESKTOP.Top = $$BX")
   execute("$$$RDESKTOP.onclick = 'OnClick($X)'")
  NEXT
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION ReadINI()
  $cnt=1
  $sarray[$cnt,0]=READPROFILESTRING($ini,"RDP"+$cnt,"TITLE")
  WHILE $sarray[$cnt,0] <> ""
   IF LEN($sarray[$cnt,0]) > $wid
    $wid = LEN($sarray[$cnt,0])
   ENDIF
   $sarray[$cnt,1]=READPROFILESTRING($ini,"RDP"+$cnt,"LOCATION")
   $sarray[$cnt,2]=READPROFILESTRING($ini,"RDP"+$cnt,"PORT")
   $sarray[$cnt,3]=READPROFILESTRING($ini,"RDP"+$cnt,"H")
   $sarray[$cnt,4]=READPROFILESTRING($ini,"RDP"+$cnt,"V")
   $cnt=$cnt+1
   IF $cnt < 99
    $sarray[$cnt,0]=READPROFILESTRING($ini,"RDP"+$cnt,"TITLE")
   ELSE
    $sarray[$cnt,0]=""
   ENDIF
  LOOP
  $cnt=$cnt-1
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION EditINI($count)
  $mainform.hide
  $title=$sarray[$count,0]
  $location=$sarray[$count,1]
  $port=$sarray[$count,2]
  $hz=$sarray[$count,3]
  $vt=$sarray[$count,4]
  AddEdit($count,$title,$location,$port,$hz,$vt)
  $restart="Y"
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION AddINI()
  $mainform.hide
  $count=$cnt+1
  IF $count<99
   $sarray[$count,0]="RDP"+CSTR($count)+" Computer"
   $sarray[$count,1]="New Computer"
   $sarray[$count,2]="3389"
   $sarray[$count,3]="1024"
   $sarray[$count,4]="768"
   AddEdit($count,$sarray[$count,0],$sarray[$count,1],$sarray[$count,2],$sarray[$count,3],$sarray[$count,4])
  ENDIF
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION AddEdit($count,$title,$locat,OPTIONAL $port,$hz,$vt)
  $aeform = CreateObject("Kixtart.Form")
  $aeform.caption = "RDP profile details"
  $aeform.width = 450
  $aeform.height = 250
  $aeform.topmost = "true"
  $aeform.maximizebox = false
  $aeform.minimizebox = false
  $aeform.center

  BldPForm("AEform",130,10,"TCPIP Address or NAME",20,"TCPIP",,,,$locat)
  BldPForm("AEform",130,45,"Button Title",20,"TITLE",,,,$title)
  BldPForm("AEform",130,80,"IP Port No {OPTIONAL}",20,"PORT",,,,$port)
  BldPForm("AEform",130,115,"Horizontal Resolution",5,"HZ",,,,$hz)
  BldPForm("AEform",130,150,"Vertical Resolution",5,"VT",,,,$vt)

  $buttonok = $aeform.commandbutton("Accept",130,186,60,20)
  $buttonok.default = 1
  $buttonok.fontbold = 1
  $buttonok.onclick = 'BOK($count)'

  $buttonca = $aeform.commandbutton("Cancel",200,186,60,20)
  $buttonca.default = 1
  $buttonca.fontbold = 1
  $buttonca.onclick = "BCA()"

  $buttonde = $aeform.commandbutton("Delete",270,186,60,20)
  $buttonde.default = 1
  $buttonde.fontbold = 1
  $buttonde.onclick = "BDE($count)"


  $title.focus()

  $aeform.show
  WHILE $aeform.visible
   $=Execute($aeform.doevents())
  LOOP
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION WriINI($count)
  IF (OPEN(9,$ini,5)) = 0
   Writeline(9,'[RDP'+CSTR($count)+']'+@crlf)
   Writeline(9,'TITLE="'+$sarray[$count,0]+'"'+@crlf)
   Writeline(9,'LOCATION="'+$sarray[$count,1]+'"'+@crlf)
   Writeline(9,'Port="'+$sarray[$count,2]+'"'+@crlf)
   Writeline(9,'H="'+$sarray[$count,3]+'"'+@crlf)
   Writeline(9,'V="'+$sarray[$count,4]+'"'+@crlf+@crlf)
   Close (9)
  ELSE
   MESSAGEBOX ($ini+" Cannot be created."+@crlf+@crlf+">>>> Please seek assistance <<<<", "ERROR "+@serror, 0, 30)
  ENDIF
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION BOK($no)
  IF Exist($ini+".OLD")
   DEL $ini+".OLD"
  ENDIF
  MOVE $ini $ini+".OLD"
  IF NOT exist($ini)
   $sarray[$no,0] =$title.text
   $sarray[$no,1] =$tcpip.text
   $sarray[$no,2] =$port.text
   $sarray[$no,3] =$hz.text
   $sarray[$no,4] =$vt.text
   $cnt=$no
   FOR $x = 1 TO $cnt
    WriINI($x)
   NEXT
   $restart="Y"
  ENDIF
  $aeform.hide
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION BCA()
  $aeform.hide
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION BDE($no)
  IF Exist($ini+".OLD")
   DEL $ini+".OLD"
  ENDIF
  MOVE $ini $ini+".OLD"
  IF NOT exist($ini)
   FOR $x = $no TO $cnt-1
    FOR $y = 0 TO 4
     $sarray[$x,$y] = $sarray[$x+1,$y]
    NEXT
   NEXT
   $cnt=$cnt-1
   FOR $x = 1 TO $cnt
    WriINI($x)
   NEXT
   $restart="Y"
  ENDIF
  $aeform.hide
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION ONClick($no)
  IF $edini.checked = 0
   RDP($no)
  ELSE
   EditINI($no)
  ENDIF
 ENDFUNCTION

 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION RDP($no)
  $mainform.hide
  IF $sarray[$no,2] = ""
   $sarray[$no,2] = "3389"
  ENDIF
  IF $sarray[$no,1] = ""
   EXIT 1
  ELSE
   IF $sfull.checked <> 0
    $cmd = "mstsc.exe /v:"+$sarray[$no,1]+":"+$sarray[$no,2]+" /F /PUBLIC"
   ELSE
    $cmd = "mstsc.exe /v:"+$sarray[$no,1]+":"+$sarray[$no,2]+" /w:"+$sarray[$no,3]+" /h:"+$sarray[$no,4]+" /PUBLIC"
   ENDIF
   SHELL $cmd
  ENDIF
  $mainform.show
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION BldPForm($form,$lx,$ly,$label,$tbsize,$vlabel,OPTIONAL $fmt, OPTIONAL $ml, OPTIONAL $count, OPTIONAL $seedval )
  ;Note $$# is a means of getting execute to resolve correctly.
  $tbn="$"+$vlabel
  $lbl="$L"+right($vlabel,-1)
  IF $count <> ""
   $lbc = "$C" + right($vlabel,-1)
   $_ = execute("$$#$LBC = $$$form.label()")
   $_ = execute("$$#$LBC.fontsize=8")
   $_ = execute("$$#$LBC.Height = 23")
   $_ = execute("$$#$LBC.Top = $$LY + 5")
   $_ = execute("$$#$LBC.Left = $$LX + 6 + ($$TBSize * 13)")
   $_ = execute("$$#$LBC.FontBold = 0")
   $_ = execute("$$#$LBC.TextAlign = 0")
  ENDIF

  IF $ml="" $ml="0"
  ENDIF
  IF $fmt="" $fmt="GT"
  ENDIF
  $_ = execute("$$#$TBN = $$$Form.TextBox()")
  $_ = execute("$$#$TBN.MultiLine = $$ML")
  $_ = execute("$$#$TBN.Width = ($$TBSize * 13)+4")
  $_ = execute("$$#$TBN.Height = 28")
  $_ = execute("$$#$TBN.Left = $$LX")
  $_ = execute("$$#$TBN.Top = $$LY")
  $_ = execute("$$#$TBN.TextAlign = 0")
  $_ = execute("$$#$TBN.AcceptsReturn = 'FALSE'")
  $_ = execute("$$#$TBN.fontsize= 12")
  $_ = execute("$$#$TBN.Opacity = 100")
  $_ = execute("$$#$TBN.MaxLength = $$TBSize")
  $_ = execute("$$#$TBN.text = $$Seedval")
  IF $fmt = "YY" OR $fmt = "YYYY" OR $fmt = "DD" OR $fmt = "MM"
   $_ = execute("$$#$TBN.OnLostFocus = 'FillForm($Vlabel,$Fmt,)'")
  ELSE
   IF $count <> ""
    ;$_ = execute("$$#$TBN.OnTextChanged = 'FillForm($Vlabel,$Fmt,$TBSize)'")
    $_ = execute("$$#$TBN.OnLostFocus = 'TXTTrim($Vlabel,$TBSize)'")
   ELSE
    ;$_ = execute("$$#$TBN.OnTextChanged = 'FillForm($Vlabel,$Fmt,)'")
    $_ = execute("$$#$TBN.OnLostFocus = 'TXTTrim($Vlabel,)'")
   ENDIF
  ENDIF
  $_ = execute("$$#$LBL = $$$Form.label()")
  $_ = execute("$$#$LBL.Text = $$Label")
  $_ = execute("$$#$LBL.MultiLine = $$ML")
  $_ = execute("$$#$LBL.fontsize=8")
  $_ = execute("$$#$LBL.Width = len($$Label) * 13")
  $_ = execute("$$#$LBL.Height = 24")
  $_ = execute("$$#$LBL.Top = $$LY + 5")
  $_ = execute("$$#$LBL.Right = $$LX - 5")
  $_ = execute("$$#$LBL.FontBold = 0")
  $_ = execute("$$#$LBL.TextAlign = 4")
  DEBUG OFF
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION TXTTrim($vlabel,OPTIONAL $tbsize)
  $lbc = "$C" + right($vlabel,-1)
  $tbn = "$"+$vlabel
  $ = execute("$$TEXTX = $$TBN + '.TEXT'")
  $ = execute("$$TEXTC = $TEXTX")
  WHILE right($textc,1)= "_"
   $textc = left($textc,-1)
  LOOP
  WHILE left($textc,1)= "_" OR left($textc,1)= " "
   $textc = right($textc,-1)
  LOOP
  IF $tbsize <>""  ;Reduce letter count if required
   $_ = execute("$$#$LBC.Text = $$TBSize - len($$TEXTC)")
  ENDIF
  $_ = execute("$$#$TBN.Text = $$TEXTC")
 ENDFUNCTION


EXAMPLE RDP.INI

[RDP1]
TITLE="SERVER01"
LOCATION="192.168.11.11"
Port=""
H="1024"
V="768"

[RDP2]
TITLE="SERVER02"
LOCATION="192.168.11.12"
Port=""
H="1024"
V="768"
________
Free Gift Card


Last edited by MACE1 on Fri Feb 18, 2011 5:06 pm; edited 1 time in total
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Tue Jan 23, 2007 12:35 pm    Post subject: Reply with quote

In no way is this meant to be a working script (I have run out of time at this moment to continue)

Hopefully it will give you some where to start looking. I will warn you now that there are many Vars that are undeclared and the script as I have modified it will beep until you fix that.

If you have questions feel free to ask away...

Code:

;Quick launch RDP on Windows 2K/XP
 CLS ; <---- Not needed if you launch with WKix32

;Putting these options at the beginning of your script will
;make you a better scripter

$SO=SETOPTION("Explicit", "ON")
$SO=SETOPTION("NoMacrosInStrings", "ON")
$SO=SETOPTION("NoVarsInStrings", "ON")
$SO=SETOPTION("WrapAtEOL", "ON")


If Not @Logonmode  ; Now considered best practice
 BREAK ON
EndIf

;declerations

GLOBAL $ini,$cnt,$wid,$restart,$sarray[99,5]
Global $system,$mainform,$sfull,$swind,$sadini,$adlab
Global $edini,$wx,$wy


$restart=""
$ini=@scriptdir+"\RDP.ini"

$system = CreateObject("Kixtart.System")

If Not $System
   $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf

$mainform = $system.form()
$mainform.caption = "RDP profiles [" + $cnt + "]"
$mainform.width = $wx + 110
$mainform.height = $wy + 10
$mainform.topmost = "true"
$mainform.maximizebox = "false"
$mainform.minimizebox = "false"
$mainform.center

MakeBtns($wx,$wy)

$sfull = $mainform.controls.radiobutton()
$sfull.left = $wx + 18
$sfull.top  = 7
$sfull.text = "Full Screen"
$sfull.checked = "False"
$sfull.height = 24
$sfull.width = 80
$sfull.tabstop = "True"

$swind = $mainform.controls.radiobutton()
$swind.left = $wx + 18
$swind.top  = 28
$swind.text = "Windowed"
$swind.checked = "True"
$swind.height = 24
$swind.width = 80
$swind.tabstop = "True"

$adini= $mainform.controls.button()
$adini.height = 12
$adini.width = 12
$adini.left = $wx + 19
$adini.top = $wy - 70
$adini.onclick = 'AddINI()'

$adlab = $mainform.controls.label()
$adlab.height = 12
$adlab.width = 60
$adlab.left = $wx + 36
$adlab.top = $wy - 70
$adlab.text = "Add profile"

$edini= $mainform.controls.checkbox()
$edini.text = "Edit profile"
$edini.height = 20
$edini.width = 80
$edini.left = $wx + 19
$edini.top = $wy - 54
$edini.checkalign = 16
$edini.checked = "False"


IF Not left(@producttype,10) = "Windows XP" OR  left(@producttype,10) = "Windows 20"
     MESSAGEBOX ("This requires Windows 2000/XP or newer to run.",@producttype, 0, 0) 
   Quit ()
EndIf

IF exist($ini)
   ReadINI()
    $wy=($cnt*22) + 40
ELSE
    $cnt=0
    AddINI()
   ReadINI()
ENDIF

IF $cnt < 4 $wy = 125 ENDIF
IF $wx <100 $wx = 100 ENDIF


$mainform.show


WHILE $mainform.visible
   $=Execute($mainform.doevents())
LOOP


 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION MakeBtns($wx,$wy)

  FOR $x = 1 TO $cnt
   $rdesktop="RDP"+$x
   $bx=($x*22)-15
   execute("$$$RDESKTOP= $$MainForm.Controls.Button()")
   execute("$$$RDESKTOP.text = $$SArray[$$x,0]")
   execute("$$$RDESKTOP.Height = 20")
   execute("$$$RDESKTOP.Width = $$WX")
   execute("$$$RDESKTOP.Left = 8")
   execute("$$$RDESKTOP.Top = $$BX")
   execute("$$$RDESKTOP.onclick = 'OnClick($X)'")
  NEXT
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION ReadINI()
  $cnt=1
  $sarray[$cnt,0]=READPROFILESTRING($ini,"RDP"+$cnt,"TITLE")
  WHILE $sarray[$cnt,0] <> ""
   IF LEN($sarray[$cnt,0]) > $wid
    $wid = LEN($sarray[$cnt,0])
   ENDIF
   $sarray[$cnt,1]=READPROFILESTRING($ini,"RDP"+$cnt,"LOCATION")
   $sarray[$cnt,2]=READPROFILESTRING($ini,"RDP"+$cnt,"PORT")
   $sarray[$cnt,3]=READPROFILESTRING($ini,"RDP"+$cnt,"H")
   $sarray[$cnt,4]=READPROFILESTRING($ini,"RDP"+$cnt,"V")
   $cnt=$cnt+1
   IF $cnt < 99
    $sarray[$cnt,0]=READPROFILESTRING($ini,"RDP"+$cnt,"TITLE")
   ELSE
    $sarray[$cnt,0]=""
   ENDIF
  LOOP
  $cnt=$cnt-1
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION EditINI($count)
  $mainform.hide
  $title=$sarray[$count,0]
  $location=$sarray[$count,1]
  $port=$sarray[$count,2]
  $hz=$sarray[$count,3]
  $vt=$sarray[$count,4]
  AddEdit($count,$title,$location,$port,$hz,$vt)
  $restart="Y"
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION AddINI()
  $mainform.hide
  $count=$cnt+1
  IF $count<99
   $sarray[$count,0]="RDP"+CSTR($count)+" Computer"
   $sarray[$count,1]="New Computer"
   $sarray[$count,2]="3389"
   $sarray[$count,3]="1024"
   $sarray[$count,4]="768"
   AddEdit($count,$sarray[$count,0],$sarray[$count,1],$sarray[$count,2],$sarray[$count,3],$sarray[$count,4])
  ENDIF
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION AddEdit($count,$title,$locat,OPTIONAL $port,$hz,$vt)
  $aeform = CreateObject("Kixtart.Form")
  $aeform.caption = "RDP profile details"
  $aeform.width = 450
  $aeform.height = 250
  $aeform.topmost = "true"
  $aeform.maximizebox = false
  $aeform.minimizebox = false
  $aeform.center

  BldPForm("AEform",130,10,"TCPIP Address or NAME",20,"TCPIP",,,,$locat)
  BldPForm("AEform",130,45,"Button Title",20,"TITLE",,,,$title)
  BldPForm("AEform",130,80,"IP Port No {OPTIONAL}",20,"PORT",,,,$port)
  BldPForm("AEform",130,115,"Horizontal Resolution",5,"HZ",,,,$hz)
  BldPForm("AEform",130,150,"Vertical Resolution",5,"VT",,,,$vt)

  $buttonok = $aeform.commandbutton("Accept",130,186,60,20)
  $buttonok.default = 1
  $buttonok.fontbold = 1
  $buttonok.onclick = 'BOK($count)'

  $buttonca = $aeform.commandbutton("Cancel",200,186,60,20)
  $buttonca.default = 1
  $buttonca.fontbold = 1
  $buttonca.onclick = "BCA()"

  $buttonde = $aeform.commandbutton("Delete",270,186,60,20)
  $buttonde.default = 1
  $buttonde.fontbold = 1
  $buttonde.onclick = "BDE($count)"


  $title.focus()

  $aeform.show
  WHILE $aeform.visible
   $=Execute($aeform.doevents())
  LOOP
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION WriINI($count)
  IF (OPEN(9,$ini,5)) = 0
   Writeline(9,'[RDP'+CSTR($count)+']'+@crlf)
   Writeline(9,'TITLE="'+$sarray[$count,0]+'"'+@crlf)
   Writeline(9,'LOCATION="'+$sarray[$count,1]+'"'+@crlf)
   Writeline(9,'Port="'+$sarray[$count,2]+'"'+@crlf)
   Writeline(9,'H="'+$sarray[$count,3]+'"'+@crlf)
   Writeline(9,'V="'+$sarray[$count,4]+'"'+@crlf+@crlf)
   Close (9)
  ELSE
   MESSAGEBOX ($ini+" Cannot be created."+@crlf+@crlf+">>>> Please seek assistance <<<<", "ERROR "+@serror, 0, 30)
  ENDIF
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION BOK($no)
  IF Exist($ini+".OLD")
   DEL $ini+".OLD"
  ENDIF
  MOVE $ini $ini+".OLD"
  IF NOT exist($ini)
   $sarray[$no,0] =$title.text
   $sarray[$no,1] =$tcpip.text
   $sarray[$no,2] =$port.text
   $sarray[$no,3] =$hz.text
   $sarray[$no,4] =$vt.text
   $cnt=$no
   FOR $x = 1 TO $cnt
    WriINI($x)
   NEXT
   $restart="Y"
  ENDIF
  $aeform.hide
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION BCA()
  $aeform.hide
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION BDE($no)
  IF Exist($ini+".OLD")
   DEL $ini+".OLD"
  ENDIF
  MOVE $ini $ini+".OLD"
  IF NOT exist($ini)
   FOR $x = $no TO $cnt-1
    FOR $y = 0 TO 4
     $sarray[$x,$y] = $sarray[$x+1,$y]
    NEXT
   NEXT
   $cnt=$cnt-1
   FOR $x = 1 TO $cnt
    WriINI($x)
   NEXT
   $restart="Y"
  ENDIF
  $aeform.hide
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION ONClick($no)
  IF $edini.checked = 0
   RDP($no)
  ELSE
   EditINI($no)
  ENDIF
 ENDFUNCTION

 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION RDP($no)
  $mainform.hide
  IF $sarray[$no,2] = ""
   $sarray[$no,2] = "3389"
  ENDIF
  IF $sarray[$no,1] = ""
   EXIT 1
  ELSE
   IF $sfull.checked <> 0
    $cmd = "mstsc.exe /v:"+$sarray[$no,1]+":"+$sarray[$no,2]+" /F /PUBLIC"
   ELSE
    $cmd = "mstsc.exe /v:"+$sarray[$no,1]+":"+$sarray[$no,2]+" /w:"+$sarray[$no,3]+" /h:"+$sarray[$no,4]+" /PUBLIC"
   ENDIF
   SHELL $cmd
  ENDIF
  $mainform.show
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION BldPForm($form,$lx,$ly,$label,$tbsize,$vlabel,OPTIONAL $fmt, OPTIONAL $ml, OPTIONAL $count, OPTIONAL $seedval )
  ;Note $$# is a means of getting execute to resolve correctly.
  $tbn="$"+$vlabel
  $lbl="$L"+right($vlabel,-1)
  IF $count <> ""
   $lbc = "$C" + right($vlabel,-1)
   $_ = execute("$$#$LBC = $$$form.label()")
   $_ = execute("$$#$LBC.fontsize=8")
   $_ = execute("$$#$LBC.Height = 23")
   $_ = execute("$$#$LBC.Top = $$LY + 5")
   $_ = execute("$$#$LBC.Left = $$LX + 6 + ($$TBSize * 13)")
   $_ = execute("$$#$LBC.FontBold = 0")
   $_ = execute("$$#$LBC.TextAlign = 0")
  ENDIF

  IF $ml="" $ml="0"
  ENDIF
  IF $fmt="" $fmt="GT"
  ENDIF
  $_ = execute("$$#$TBN = $$$Form.TextBox()")
  $_ = execute("$$#$TBN.MultiLine = $$ML")
  $_ = execute("$$#$TBN.Width = ($$TBSize * 13)+4")
  $_ = execute("$$#$TBN.Height = 28")
  $_ = execute("$$#$TBN.Left = $$LX")
  $_ = execute("$$#$TBN.Top = $$LY")
  $_ = execute("$$#$TBN.TextAlign = 0")
  $_ = execute("$$#$TBN.AcceptsReturn = 'FALSE'")
  $_ = execute("$$#$TBN.fontsize= 12")
  $_ = execute("$$#$TBN.Opacity = 100")
  $_ = execute("$$#$TBN.MaxLength = $$TBSize")
  $_ = execute("$$#$TBN.text = $$Seedval")
  IF $fmt = "YY" OR $fmt = "YYYY" OR $fmt = "DD" OR $fmt = "MM"
   $_ = execute("$$#$TBN.OnLostFocus = 'FillForm($Vlabel,$Fmt,)'")
  ELSE
   IF $count <> ""
    ;$_ = execute("$$#$TBN.OnTextChanged = 'FillForm($Vlabel,$Fmt,$TBSize)'")
    $_ = execute("$$#$TBN.OnLostFocus = 'TXTTrim($Vlabel,$TBSize)'")
   ELSE
    ;$_ = execute("$$#$TBN.OnTextChanged = 'FillForm($Vlabel,$Fmt,)'")
    $_ = execute("$$#$TBN.OnLostFocus = 'TXTTrim($Vlabel,)'")
   ENDIF
  ENDIF
  $_ = execute("$$#$LBL = $$$Form.label()")
  $_ = execute("$$#$LBL.Text = $$Label")
  $_ = execute("$$#$LBL.MultiLine = $$ML")
  $_ = execute("$$#$LBL.fontsize=8")
  $_ = execute("$$#$LBL.Width = len($$Label) * 13")
  $_ = execute("$$#$LBL.Height = 24")
  $_ = execute("$$#$LBL.Top = $$LY + 5")
  $_ = execute("$$#$LBL.Right = $$LX - 5")
  $_ = execute("$$#$LBL.FontBold = 0")
  $_ = execute("$$#$LBL.TextAlign = 4")
  DEBUG OFF
 ENDFUNCTION
 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 FUNCTION TXTTrim($vlabel,OPTIONAL $tbsize)
  $lbc = "$C" + right($vlabel,-1)
  $tbn = "$"+$vlabel
  $ = execute("$$TEXTX = $$TBN + '.TEXT'")
  $ = execute("$$TEXTC = $TEXTX")
  WHILE right($textc,1)= "_"
   $textc = left($textc,-1)
  LOOP
  WHILE left($textc,1)= "_" OR left($textc,1)= " "
   $textc = right($textc,-1)
  LOOP
  IF $tbsize <>""  ;Reduce letter count if required
   $_ = execute("$$#$LBC.Text = $$TBSize - len($$TEXTC)")
  ENDIF
  $_ = execute("$$#$TBN.Text = $$TEXTC")
 ENDFUNCTION

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Tue Jan 23, 2007 1:25 pm    Post subject: Thanks Gargoyl, I think... Reply with quote

As I am not a frequent scripter, I use what I can glean from past examples. Whereas declaring everything Explicitly is very fine, it is not essential or particularly pertinent to the overall question in so much as it will work fine as is...Yes I will go through it and declare everything if you insist...
I just can't find out what method to employ to restart the primary form without a goto or else going into a bottomless loop &/or breaking the script.
NB: I know NOTHING about .net
________
FERRARI 166 S HISTORY


Last edited by MACE1 on Fri Feb 18, 2011 5:06 pm; edited 1 time in total
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Tue Jan 23, 2007 4:54 pm    Post subject: Reply with quote

If you want to remove the setoptions that is up to you...

As for the looping, by removing the form from the If -- Endif and building it and doing all of your setup before hand, should resolve at least some it.

I did not have a chance to go through all of your functions, so the clean up that was provided was only in the "main" portion of your script.

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Tue Jan 23, 2007 9:28 pm    Post subject: Explicit and NoVarsInStrings = off for BldForm and MakeBtns Reply with quote

BldForm and MakeBtns is the only efficient method I have come across to date for recursivley generating buttons etc. If anyone can come up with another alternative which is less of a pain and equally as small - does not require coding every button, I would happily switch.
Unfortunately I have to admit defeat getting it to execute(Dim $###) correctly. Looks OK when debugging but form ends up blank.

Took on board other comments and restructured as much as I can and eliminated the goto but main problem persists regarding 'regenerating' the main form. Works first time, not next, then 3rd. I am not sure what is required before I ask Kix to redraw the same forms again, possibly at different size with more or less buttons.

NB: What should I check for to see if mainform has had X close selected.
I would like to trap the event to set $Restart="N"
________
WEED NEWS


Last edited by MACE1 on Fri Feb 18, 2011 5:07 pm; edited 1 time in total
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Wed Jan 24, 2007 1:49 am    Post subject: Reply with quote

I will have some time on Wednesday to work with this. I will post updates after I get through the whole thing
_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Thu Jan 25, 2007 12:18 pm    Post subject: Reply with quote

Ok, work and life got the better of me yesterday and I did not have a chance to work on this.

One of things that I am noticing is that you are using KiXforms.Net, yet many of commands are done in KiXforms Classic.

The .Net version is a complete rewrite of KiXforms, you will need to visit the .Net forum to see the many threads and discussions about it.

I am not trying to be judgemental here, but why are you building this form / script to create RDP profiles when you could just define what they are, and then save them to a common share point? Or am I missing the idea behind this?

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Thu Jan 25, 2007 1:23 pm    Post subject: WHY RDP Reply with quote

I have a folder full of DOZENS of RDP profiles.
The New release of Remote Desktop has got ANNOYING.
I wanted something tidier, always available, Invisible when I window to numerous workstations and servers...etc
Apart from that it is slow and large opening an explorer windows these days whereas this is quick, compact and I can quickly set what I need without the rigmarole of editing the RDP profile. I employ this type of code across numerous tasks, the RDP being the latest and the issue raised a common one.

As to why .net
I only know traditional kix but more and more of the examples I use to get me where I need to be are not working so I have to go and find new ones. If what I find is written for .net, most of the time I would not know the difference, not being a programmer and not giving it a great deal of time bar little projects like this. I fully appreciate the basics of good coding but on the other hand time and other restraints mean I stitch together working code from a variety of sources.
The BldForm example has worked well for me for a couple of years over numerous menu systems, RDP included however it is becoming obvious I need an alternative from your comments and from what I am unable to do with the new builds. Does not work with Shaun?s latest KIXform.dll
I am having to try and understand the differences between the different models and know of no useable source to identify what has been depreciated and what is accepted good practice. If I was doing this on a daily basis I would be up to speed but it has been MONTHS since any serious coding.
Point me at 'XYZ' for this task and I can happily interpret and employ, however I don't have resource to start from first principles.

I am under the impression that once a FORM is created, components added etc, even if the while..do events...loop is complete and the form is hidden IT STILL EXISTS until the script exits. My issue I feel is I am effectively trying to re-create what already exists which causes it to fail/work/fail whereas I need to understand how to resize and add remove components.
I even put the :
$system = CreateObject("Kixtart.System")
$mainform = $system.form()
$sfull = $mainform.controls.radiobutton() etc
outside the restart="Yes" scope/loop so only the new dimensions and values are applied, the form and component is not recreated...but to no avail, still the same issue.
I know I am missing a part of the puzzle but am damned if I know where to look to find the key !
I am open to constructive advice from all as I know I DONT KNOW enough.
I would love to know for example where the .net components are classified. I keep referring to the included .chm and online equivalent to find events, components etc but it is like 'Teach yourself English' using only a dictionary !
________
VAPIR OXYGEN VAPORIZER


Last edited by MACE1 on Fri Feb 18, 2011 5:07 pm; edited 1 time in total
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Thu Jan 25, 2007 5:59 pm    Post subject: Reply with quote

I will continue working on your presented code then, and point out things I notice specifically as I go. This may take me awhile as we are short handed at work, and I am doing the job of 2, and already had to much work.
_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Thu Jan 25, 2007 7:43 pm    Post subject: No hurry, it works as it is all be it using old style code. Reply with quote

I know the feeling, I am the ONLY IT support in our company, and get to do lots more besides.
Drop me a note as and when...
________
No2 review


Last edited by MACE1 on Fri Feb 18, 2011 5:07 pm; edited 1 time in total
Back to top
View user's profile Send private message
MACE1
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 12 Oct 2004
Posts: 130
Location: Manchester UK

PostPosted: Tue Mar 06, 2007 5:29 pm    Post subject: Less of a FIX more of a Work-arround Reply with quote

Idea
As the issue was re-generating, re-sizing etc and I was not sure where to start, I opted to let the script exit and restart anew.

Code:

IF $restart="Y"
 $run='"'+@startdir+"\"+@scriptexe+'" "'+@scriptdir+"\"+@scriptname+'" /I'
  run $run
ENDIF
Exit

________
Jugallette
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group