### Copyright (C) 1996 Rasmus Ingemann Hansen
### This program is free software; you can redistribute it and/or modify
### it under the terms of the GNU General Public License as published by
### the Free Software Foundation; either version 2 of the License, or
### (at your option) any later version.
###
### This program is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
### GNU General Public License for more details.
###
### You should have received a copy of the GNU General Public License
### along with this program; if not, write to the Free Software
### Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


proc version {} {
    # Version
    Desc "Select which version of Elm you want to generate for. If in doubt, try \"elm -v\" and you will be given version and configuration information."
    ShortDesc "Elm version"

    Header head1 -text "Patchlevel for Elm version 2.4"\
	-background gray\
	-help "This module is able to generate options for Elm version 2.4 only. The default is for PatchLevel (PL) 23.  If you are on a HP machine, you can find high version numbers like 60.25 or 70.85. HP have derived them from Elm and have added some features. If version number is <70 you can consider upgrading to 2.4.23, otherwise it's a matter of choice."

    Label label01 \
	-text "Beware: wait for the next release for\nspecific PL25 upcodes!"

    CheckBox versionCheckBox1 \
	-text "You want to use Elm on a HP machine" \
	-help "eases choice of version"

    Line line0

    Radio versionRadio1 \
	-text "Generate for which (HP) version:" \
	-defaultIndex 0 \
	-entryhelp {"60(.25)" "" \
	            "66(.25)" "" \
	            "70(.85)" ""
	} \
	-help "If in doubt, try \"elm -v\"" \
	-packFrame:fill x

    Line line1

    Radio versionRadio2 \
	-text "Generate for which (non HP) version:" \
	-defaultIndex 0 \
	-entryhelp {"PL 23" "PL23 version. If Elm not available or tag expression \"PL\" couldn't be extracted, \"PL23\" is set by default." \
	            "PL 24" "PL24 version" \
	            "PL 25" "Patch Level 25. Version 2.5 will be the next (major) official release. This release was not included in this version of the Elm Module for the Dotfile Generator."
	} \
	-help "This module is by default PL23 version. Selecting a higher version gains more (newer less) options to the different pages. If in doubt, try \"elm -v\"" \
	-packFrame:fill x

    Line line11

    Label elmvers -text "Apparently Elm (Ver2.4) reports:" \
	-help "This information is extracted from \"elm -v\". If Elm not available or tag expression \"PL\" couldn't be extracted, \"PL23\" is set as default."


  ################################ Change #################################
    Change {
	if {$versionCheckBox1==0} {
		Enable versionRadio2
		Disable versionRadio1
	} else {
		Enable versionRadio1
		Disable versionRadio2
	}

    }

    Init {
	catch {[exec elm -v]} temp
	# get out "PL":
	if ![regexp {(.*)PL(.*)$} $temp all prefix buff] {		
		set buff "?"
	}
	set versionCheckBox1 0
	if {$buff=="?"} {
		# set PL23 as default, even if 'PL" not found:
		set versionRadio2(index) 0
		set elmvers "\"?\""
	} else {
		# get the PL-number "xx":
		regexp {..} $buff all prefix buff

		if {$all=="60"} {
			set versionRadio1(index) 0
			set versionCheckBox1 1
		} elseif {$all=="66"} {
			set versionRadio1(index) 1
			set versionCheckBox1 1
		} elseif {$all=="70"} {
			set versionRadio1(index) 2
			set versionCheckBox1 1
		} elseif {$all=="23"} {
			set versionRadio2(index) 0
		} elseif {$all=="24"} {
			set versionRadio2(index) 1
		} elseif {$all=="25"} {
			set versionRadio2(index) 2
		} else {
			# default is PL23 (and if not found)
			set versionRadio2(index) 0
		}
		
		# set the label reporting patchlevel:
		set elmvers "\"$all\""
	}
    }
}






