
! script name: layers.d/setcurrcmpnt
! topic: assign current component

!A
!A NAME:
!A
!A 	Change Current Component
!A
!A DESCRIPTION:
!A
!A 	This script allows the current component to be defined.  The default
!A 	component is "0".
!A
!B INSTRUCTIONS:
!B
!B 	COMPONENT NUMBER   current component = #: 
!B 		Enter the component number to be used.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: change current component ")

DIM Destination$[256]
DIM Answer$[256]

CALL Convert_old_origins
Component=CurrentComponent

stat= SetInputFormat("n0=","")
Component=InputComponent("COMPONENT NUMBER"&"   current component = "&VAL$(Component))
IF (ExitScript(Destination$)) THEN Leave

Stat=SetCurrComponent(Component)

Leave:!
stat= SetInputFormat("n4","")
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END

SUB Convert_old_origins
DIM Answer$[256]
DIM Zone_name$[256]

G1= UserDataGroup(WsWorkZoneOrigin)
IF NOT ValidGeometry(G1) THEN SUBEXIT
Num_origins= GroupCount(G1)

FOR I= 1 TO Num_origins
        E1= GroupElement(G1,I)
        IF CheckUserField(E1,"Class id number:",1) THEN Next_i
        Group1= GrpByProp(E1,WsWorkZoneOrigin)
        IF NOT ValidGeometry(Group1) THEN Next_i
        IF NOT GroupCount(Group1) THEN Next_i
	GOTO End_it
Next_i: NEXT I
Stat=DeleteEntity(G1)
SUBEXIT
End_it:	Answer$="/usr/weber/database/messages/convert_old_zones"
	Stat=MessageFileBox(Answer$,"INFORMATION")
	Stat=DeleteEntity(G1)
	Stat=DeleteEntity(Group1)
SUBEND
