String check

Hi,
I have a number which is char(30).I have to check whether this number begin with ARD4*,if any other value raise error.
Please do help me
Thanks&Regards,
Madhavi.

Hi,  try this.
if v_value+0(4) = 'ARD4'.
* do something.
Endif.
Regards,
Rich Heilman

Similar Messages

  • String check problem

    I have a doozy of a problem on my hands. My company has introduced a password policy that every user must me now. Some of my criteria is that a password must contain at least one symbol and at least one number. In 10g I can use REGEXP_LIKE function, but I am running 9i. I have tried to use translate, OWA_PATTERN function, everthing. How can I take a string variable, and test to see if there is a symbol in the text or a number. I want to be able to return a true/false value?
    Please advise?

    Like Kamal says, use built-in functionality FIRST.
    Failing that, presumably you would write something like this (I forget the exact naming standard for the password verify function).
    CREATE FUNCTION valid_password (
       p_password IN VARCHAR2)
       RETURN BOOLEAN
    IS
       FUNCTION contains_at_least_one (
          p_string IN VARCHAR2,
          p_characters IN VARCHAR2)
          RETURN BOOLEAN
       IS
       BEGIN
          RETURN LENGTH (TRANSLATE (p_string, 'X' ||
            p_characters, 'X')) < LENGTH (p_string);
       END;
    BEGIN
       RETURN contains_at_least_one (p_password, '0123456789')
          AND contains_at_least_one (p_password, '!£$%^&*(){}~@??|<>');
    END;

  • String Checking

    Hi,
    i have a problem with password checking. my password do have some constraints. first, it can contain lower character, but this is not a must. But, when the password contains lower characters, it is limited to [abcde]. second, it must contain a number, with minimum occurence one. the number have to be [1-9].
    examples :
    "abc" invalid (doesnt contains number)
    "abc01" valid
    "00912" valid
    "abzxy77" invalid (contains zxy)
    i tried to solve it using regex in java, but i cant figure out how to let the password contains lower number in [abcde], but ensures that it contains of minimum one number.
    need help,
    thanks

    Condition should be like
    if(contains[0-9] && !contains[e-z])

  • Need help with a for loop - string checking

    I am trying to create a for loop to make sure a user entered string contains only letters but something doesn't take. No errors, but the inner loop of try again doesn't ever come into play. What am I missing please.
         String k = keyboard.nextLine();
         for (int i = 0; i < k.length(); i++)
              char c = k.charAt(i);
              int m = c; 
              if (((m < 97) && (m > 122)) || ((m < 65) && (m > 90)))
                        System.out.print("Try again please: ");
                        k = keyboard.nextLine();
    System.out.println(k);

    molested,
    (you and BigDaddyLoveHandles should get on well)
    I would use regular expression for that... which would look something like this...
    // get response containing at least one letter.
    while (true) {
      String response = keyboard.nextLine();
      if( response.matches("[a-zA-Z]+") ) break;
      System.out.print("Try again please: ");
    }Message was edited by: corlettk - frog got the {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Search string for 3 digit check number?

    For electronic bank statement,uploading file contains 3-digit check number eg;416
    but in FCHI-Check lots we defined six-digit check numbers.
    so system is not able match the check nos. as they are different, and auto reco is not happening.
    we have gone through search strings documentation but
    we dont know what to enter in search strings configuration.
    Kindly help me what to enter for 3 digit check no?
    Edited by: KUMAR on Dec 2, 2008 1:35 PM

    You'll first need to create search strings to "find" the check numbers in the note to payee information.  Then when you set up the search string use, you'll assign a mapping prefix of "000000" to format the check numbers with the leading zeros so they are 6-digits long.
    To set up the search string, you'll need to look at the note to payee information at the text either before or after the check numbers.  Let's say, for example, that the word "CHECK" always preceeds the check numbers in the note to payee:
    CHECK 456
    or
    CHECK 1234
    Because you have some check numbers coming through the bank statement as 3 digits and some as 4 digits, I'm thinking you'll need to set up two search strings, one with search string value "CHECK ###" and the following mapping:
    C ->
    H ->
    E ->
    C ->
    K ->
       ->
    -> #
    -> #
    -> #
    And the second with search string "CHECK ####" and the following mapping:
    C ->
    H ->
    E ->
    C ->
    K ->
       ->
    -> #
    -> #
    -> #
    -> #
    In the search string use, you assign each search string to the relevant company code, house bank and account ID. You can also leave these fields blank, in which case the search strings will be relevant for all company codes, house banks and accounts IDs.  You'll also need to populate the interpretation algorithm with the same algorithm that you assigned in the Global EBS config for the external transaction for checks.  The target field should be Check-/DME Reference-/Assignment number.  Fill in the mapping prefix with 000000 - and be sure to check the Active indicator.  If you are on ECC 6.0, you will also have fields for external transaction and +- (these fields may also be available in ECC 5.0 - but I know they are not available in 4.7 or prior).  If you see these fields, you can fill them in to further limit when the search string is used - for example, only for Negative transactions or only for Negative transactions with a particular external transaction value.
    Let me know if you have any other questions.
    Regards,
    Shannon
    Edited by: Shannon Moberg on Dec 3, 2008 6:05 PM

  • How can I stop a task sequence if a custom HTA preflight check fails?

    In our currently deployment method, we launch an HTA program before initiating the OSD process. This is only when run from the RAP menu, not via PXE.  When a user initiates OSD through that menu, they get a message prompting them to close Outlook, and
    a countdown of 5 mins, then OSD starts.  They also have the ability to click on an 'OK' button to proceed on their own.
    I've created a new script which checks WMI if Outlook and/or OCS are open, and if the machine is running on battery, spit out a "Failed" response and stop the HTA.  I've also added a "recheck" button to re-do the check, and an 'OK
    button if people jsut want to continue.  
    I'm curious if there is a way to prevent the task sequence from continuing if any of those conditions arent met.  Currently it just pops up and says "Failed, Cannot conitue", but if they close the window, the task sequence thinks the program
    has run, and the OSD migration starts.  I'd like to be able and get the script to cancel the OSD process if a check fails.
    Has anyone had success with this, using WINXP? I'd use the MS pre-flight check but it's only for WIN7.

    Interesting. Thanks for the response.  Is there anybody out there that can assist with VBS part of the solution?
    Here's the code I'm working with.  Currently the battery piece isnt working as it should but I can figure that our, eventually.  I'd like to get Jason's proposed solution in the code.  If this isn't the right place, I'll take this somewhere
    else.
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>OSD Preflight checks</title>
    <HTA:APPLICATION
    APPLICATIONNAME="OSD Preflight checks"
    ID="objOSDPreReqChecks"
    SCROLL="no"
    CONTEXTMENU="no"
    SINGLEINSTANCE="no"
    MAXIMIZEBUTTON="no"
    MINIMIZEBUTTON="no"
    WINDOWSTATE="normal"/>
    <!-- #region STYLEs-->
    <style type="text/css">
    H1{color:Black;text-align:center;font-family: Arial, Helvetica, sans-serif;font-size: 26px;}
    p{font-family:"Arial";font-size:10px;}
    fail{color:Red;text-align:center;}
    .Version {float:left; font-size:1.0em;font-style:italic;color:#888888;font-weight:bold;}
    .Header1 {width: 180px; text-align: right;font-weight:bold;}<!-- '1st column heading -->
    H2 {font-family: Arial, Helvetica, sans-serif; text-align: center;}
    H3 {font-style: italic;}
    .style2 {width: 180px; text-align: left;}
    .Header2 {width: 150px; text-align: right;font-weight:bold;}<!-- '2nd column heading -->
    .style4 {width: 410px; text-align: left;}
    .StatusBar
    font-family: Arial, Helvetica, sans-serif;
    text-align: center;
    .hidden {display: none; visibility: hidden;}
    </style><!-- #endregion -->
    </head>
    <script language="VBScript" type="text/vbscript">
    '======================================================================================
    ' Script
    ' Version
    ' Purpose To check a machine is suitable for taking an OS deployment
    '======================================================================================
    'Features
    ' Modular design
    ' Verbose "Debug Mode"
    ' In-built data validation
    ' Custom error handling
    ' Custom error codes - 90x0
    ' Generic WMI handler
    'BUGfix: Change CLng to CDbl to avoid overflow (in GetRAM)
    'fixed - moved head section to top to become head > script > body
    'fixed - fCheckModel display with leading ,
    'fixed - fgetmodels dictionary list
    Option Explicit
    ' #region GLOBAL DECLARATIONS: Persistent fold region
    '======================================================================================
    'GLOBAL Vars
    'Things to just display (in GUI)
    Dim strRAM
    Dim strCPUInfo
    Dim strCPUName
    Dim strCPUDesc
    Dim iCPUCount
    Dim iCPUCoreCount
    Dim iRAM
    Dim strBIOSver, strBIOSDate, strBIOSInfo
    'Time related
    Dim TimerInterval 'timer to refresh HTA at start
    Dim iTimer 'abort timer
    Const iAbortTimeout=300000 'delay before window closes (in milliseconds)
    Dim pbTimerID
    Dim pbHTML
    Dim pbWaitTime
    Dim pbHeight
    Dim pbWidth
    Dim pbBorder
    Dim pbUnloadedColor
    Dim pbLoadedColor
    Dim pbStartTime
    'Dictionary
    Dim objModelsDict,colKeys,strKey 'models
    Dim objApprovedMakesDict
    'Misc GLOBAL vars
    Dim blnDebug 'set TRUE to trigger debug mode
    Dim bAbortBuild 'Boolean flag to abort or not abort
    Dim strTemp 'throwaway/scratch
    Dim strNamespace 'wmi default namespace for ANY machine
    Dim strComputer 'wmi reference to current machine, just .
    Dim strService 'WMI service
    Dim strQuery 'custom WQL
    Dim ErrMsg 'custom error messages
    Dim iErrMode 'State machine for error mode
    Dim lFlags 'WMI flag
    Dim strDisks
    'Pre-requisites - things that will cause build to abort if values do not meet spec
    Dim strHTAVendor 'Make of hardware
    Dim strHTAVendorState
    Dim strHTAModel 'Model of hardware
    Dim strHTAModelState 'Model state
    Dim strHTARAM 'RAM
    Dim strHTARAMState 'RAM state
    Dim strHTACPUSpeed 'Processor speed
    Dim strHTACPUCores 'Number of cores
    Dim strHTACPUFullInfo 'CPU + cores
    Dim strHTAHDD 'Disk info
    Dim strHTAHDDState 'Disk state
    Dim strHTACheckRAW 'NTFS check
    Dim strHTAArchitecture 'Processor support
    Dim strHTAProduct 'Product ID
    Dim strHTAOutlook 'Outlook running
    Dim strHTAOutlookState 'Outlook state
    Dim strHTABattery 'Battery check
    Dim strHTABatteryState 'Battery state
    'for WQL filters
    Dim strWQLPCInfo 'Pre-req - (1) for various inc. domain role (servers)
    Dim strWQLRAM 'Pre-req - (2) RAM
    Dim strWQLCPU 'Pre-req - CPU speed string (not int)
    Dim strWQLBootOrder 'Pre-req - Boot order string
    Dim strWQLSATAMode 'Pre-req - HDD mode
    Dim strWQLGenericBIOS
    Dim strWQLCPUCount 'Pre-req - how many CPUs
    Dim strWQLCPUInfo
    Dim strWQLFSType 'Pre-req - Check HDD not RAW (i.e. is NTFS)
    Dim strWQLDisks 'Disks
    Dim strWQLChassis 'Machine type
    Dim strWQLID 'Unique code from OEM
    Dim strWQLProc 'is Outlook running = False
    Dim strWQLBattery 'is on Battery = False
    'State
    Const cProblem = " Problem!"
    Const cRunAgain =" RunCheck: Run System Check Again"
    Const cSuccess = " Success!"
    Const cPassed=" Pass"
    Const cFail=" Fail"
    'Pre-requisite to check: SET VALUES HERE vvvvvvvvvvvvvvvv
    Const cApprovedOEM="Hewlett-Packard"
    Const LegacyOEM1="Dell Inc."
    Const LegacyOEM2="IBM"
    Const cMinimumMemoryMB = 1000 'RAM in MB
    'Const cMinimumMemoryMB = 1000000 'force fail test data RAM in MB
    Const cMinFS="NTFS"
    ' Const cMinFS="HPFS" 'force fail test data
    Const iMinCores=1
    'Const iMinCores=10099 'force fail cores test data
    Const iMinCPUSpeed=2 '20 'in GHz
    'Const iMinCPUSpeed=90000 'in GHz
    Const iMinCPUArch=32
    'Const iMinCPUArch=64
    ' #endregion
    ' To hide anything use ID.className = "hidden", to show set to "", e.g. NotFoundArea.className = "hidden"
    Sub Window_Onload
    Err.Clear
    VersionSpan.InnerText = objOSDPreReqChecks.Version 'Get version
    self.focus
    self.moveTo 100,100 'Move window top left
    StatusBar.InnerText="Validating machine..."
    document.body.style.cursor = "wait" 'hourglass cursor
    'Call PreflightChecks 'use for testing as a VBS only, otherwise HTA timer will call below
    TimerInterval = window.setInterval("PreflightChecks",10)
    End Sub
    Function PreflightChecks
    ' #region HEADER NOTES: Persistent fold region
    'Version history
    'ver 5 OCTOBER 2011 - added error handler
    'ver 3rd Nov - removed HPonly queries
    '// Solution: Custom Script for use with MDT - Adapted from hardwareinfo.vbs Mikael Nystrom – http://deploymentbunny.com
    'Typical BIOS content
    'Processor Speed = 2133/1066 MHz
    'Boot Order = Network Controller,ATAPI CD-ROM Drive,USB device,Hard Drive,Diskette Drive,PnP Device #2,PnP Device #3,PnP Device #4,PnP Device #5,PnP Device #6,PnP Device #7,PnPe #8,PnP Device #9,PnP Device #10,PnP Device #11
    'SATA (disk) mode: *IDE,--,RAID,-- or IDE,*AHCI,RAID
    'On Error Resume Next
    ' #endregion
    ' #region CONSTANTS: Persistent fold region
    '======================================================================================
    'Fields available in HP BIOS
    Const sAsset = "Notebook Asset Tag"
    Const sOwner = "Notebook Ownership Tag"
    Const sMan = "Manufacturer"
    Const sNoteModel = "Notebook Model"
    Const sCPU = "Processor Type"
    Const sCPUSpeed = "Processor Speed"
    Const sRAM = "Memory Size"
    Const sModel = "Product Name"
    Const sBIOSName ="System BIOS"
    Const sBIOSVer = "BIOS Version"
    Const sBIOSDate = "BIOS Date"
    'Other BIOS stuff you could use too
    'Const sOwnerTag = "Enter Ownership Tag"
    'Const sBIOS = "PCID"
    'Const sBIOS = "Define Custom URL"
    'Const sBIOS = "Set Alarm Time"
    'Const sBIOS = "PCID Version"
    Const TextMode="1" 'text case sensitive for dict obj
    'WMI core constants
    Const wbemFlagReturnImmediately = 16 'wmi - Causes the call to return immediately.
    Const wbemFlagForwardOnly = 32 'wmi - Causes a forward-only enumerator to be returned.
    'Forward-only enumerators are generally much faster and
    'use less memory than conventional enumerators, but don't allow calls to SWbemObject.Clone_
    'Advisory config values - as in "you want to the change these"
    Dim strHTABootOrder
    Dim strHTASATAMode
    'Dim strHTACPU
    ' #endregion
    '======================================================================================
    ' #region WQL: Persistent fold region
    lFlags = wbemFlagReturnImmediately + wbemFlagForwardOnly
    'Queries of things to check (HP)
    strWQLBootOrder = "select Name, value from HP_BIOSSetting where Name='Boot order'"
    strWQLSATAMode = "select Name, value from HP_BIOSSetting where (Name='SATA emulation' or name='SATA device mode')"
    strWQLDisks ="SELECT * FROM Win32_DiskDrive where mediatype like 'Fixed%hard disk%'" 'win32_disk only avail after W7
    strWQLFSType ="SELECT * from Win32_LogicalDisk where DriveType='3'" 'only bother with HDDs
    'Generic WMI query strings
    strWQLGenericBIOS="SELECT Manufacturer,SMBIOSBIOSVersion,ReleaseDate FROM Win32_BIOS WHERE PrimaryBIOS = True"
    strWQLCPUCount= "SELECT NumberOfProcessors,NumberOfLogicalProcessors from Win32_ComputerSystem"
    strWQLCPUInfo="SELECT Name,DataWidth,description,MaxClockSpeed,NumberofCores,NumberOfLogicalProcessors from Win32_Processor"
    strWQLPCInfo="SELECT Domain,DomainRole,SystemType,Manufacturer,Model,TotalPhysicalMemory FROM Win32_ComputerSystem"
    ' strWQLPCInfo="SELECT Domain,DomainRole,SystemType,Manufacturer FROM Win32_ComputerSystem"
    strWQLChassis="SELECT ChassisTypes from Win32_SystemEnclosure"
    strWQLID="SELECT IdentifyingNumber,UUID from Win32_ComputerSystemProduct"
    strWQLRAM="SELECT * FROM Win32_PhysicalMemory"
    strWQLProc="SELECT * FROM Win32_Process"
    strWQLBattery="SELECT * FROM BatteryStatus Where Voltage > 0"
    ' #endregion
    ' #region MAIN algorithm
    '=====================================================================================================
    ' MAIN
    'Algorithm
    '1) Check make (vendor)
    '2) Check model (in list)
    '3) Check RAM >x
    '4) Check HDD TYPE (HDD is not RAW)
    '5) Check CPU architecture
    '6) Check outlook
    '7) Check battery
    '=====================================================================================================
    'Initialise
    window.clearInterval(TimerInterval) 'Reset timer to 0
    ' blnDebug=True
    blnDebug=False
    bAbortBuild=False 'default to DON'T abort
    ' bAbortBuild=True
    'Build list of approved vendors
    Set objApprovedMakesDict = CreateObject("Scripting.Dictionary")
    objApprovedMakesDict.comparemode=VBTextCompare
    objApprovedMakesDict.add cApprovedOEM,"OK"
    objApprovedMakesDict.add LegacyOEM1,"OK"
    objApprovedMakesDict.add LegacyOEM2,"OK"
    objApprovedMakesDict.add "Lenovo","Testdata"
    If blnDebug Then Stop
    '1) all machines check make
    strHTAVendor=fCheckVendor(strWQLGenericBIOS) 'check vendor in BIOS - if vendor not approved ABORT without proceeding
    If bAbortBuild=True Then
    StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "FATAL ERROR - goodbye cruel world"
    iTimer = window.setTimeout("Abort", iAbortTimeout, "VBScript")
    Else
    StatusBar.InnerText="Vendor: " & strHTAVendor & vbTab & " " & strHTAVendorState
    '2) Discover current Model
    strHTAModel=fGetModelName(strWQLPCInfo) 'get model name from WMI
    strHTAModel=fUniversalCheckData(strHTAModel,"'Discover Model - fGetModelName'") 'validate
    Call fGetModels 'get list of all valid models (from text file)
    strHTAModel=fCheckModel(strHTAModel)
    '2a) Model number (optional)
    strHTAProduct=fGetComputerSystemProdIDNumber(strWQLID) 'manufacturer's product ID
    strHTAProduct=fUniversalCheckData(strHTAProduct,"'Discover ID - fGetComputerSystemProdIDNumber'")
    ' StatusBar.InnerText=StatusBar.InnerText & VbCrLf & vbTab & "Product Code: " & vbTab & strHTAProduct
    '3) Check installed Memory
    strHTARAM=fGetRAM(strWQLRAM) 'find RAM size
    strHTARAM=fUniversalCheckData(strHTARAM,"'Detect RAM - fCheckRAM'")
    strHTARAM=fCheckRAM(strHTARAM) 'check RAM meets req
    If strHTARAMState=cFail Then Exit Function
    '4) Disk format IS NTFS
    strDisks=fGetDrives(strWQLFSType) 'Get formatting info for all drives
    strHTACheckRAW=fUniversalCheckData(strDisks,"'Detect filesystem - fCheckNTFS'") 'Validate data
    strHTACheckRAW=fCheckNTFS(strDisks) 'Check FS format is acceptable (not RAW)
    If strHTACheckRAW=cFail Then Exit Function
    'Generic CPU calls
    strHTACPUFullInfo="CPUs:" & fGetCPUInfo(strWQLCPUInfo) & " with CPU cores:" & iCPUCoreCount
    strBIOSInfo="BIOS version: " & strBIOSver & ", dated " & strBIOSDate
    '5a) CPU Speed check (info from http://www.robvanderwoude.com/wmiexamples.php)
    strCPUInfo=WMI(strWQLCPUInfo,strNamespace) 'Get CPU details
    strTemp=split(strCPUInfo,"@"): strHTACPUSpeed=strTemp(1)
    strHTACPUSpeed=fUniversalCheckData(strHTACPUSpeed,"'Check processor - fCheckCPUSpeed'") 'Validate data
    strHTACPUSpeed=fCheckCPUSpeed(strHTACPUSpeed) 'Check CPU clock speed
    '5b) cores check
    strHTACPUCores=fUniversalCheckData(iCPUCoreCount,"Check core count - fCheckCores") 'Validate data
    iCPUCoreCount=fCheckCores(iCPUCoreCount) 'pass or fail?
    '5c) CPU address width
    strHTAArchitecture=fUniversalCheckData(strHTAArchitecture,"Check core count - fCheckCores") 'Validate data
    strHTAArchitecture=fCheckCPUArch(strHTAArchitecture)
    '6) Check outlook
    strHTAOutlook=fCheckProcess(strWQLProc)
    '7) Check Battery
    strHTABattery=fCheckBattery(strWQLBattery)
    'end checkss
    document.body.style.cursor = "default"
    'Display hardware values in GUI (in table)
    Vendor.innerhtml = strHTAVendor 'Use str...var..STATE if you want Pass/fail text instead
    Model.innerhtml = strHTAModel
    Product.innerhtml = strHTAProduct
    RAM.innerhtml = strHTARAM
    CPUspeed.innerhtml = strHTACPUSpeed
    CPUInfo.innerhtml = strHTACPUFullInfo
    HDDFS.innerhtml = strHTACheckRAW
    CapableArchitecture.innerhtml=strHTAArchitecture
    BIOSversion.innerhtml = strBIOSver
    BIOSDate.innerhtml = strBIOSDate' CPUName.innerhtml = strCPUDesc 'GetCPUName
    End If
    '======================================================================================
    ' #endregion
    End Function
    'generic WMI queries, by field and namespace
    Function WMI(strQuery,strNameSpace)
    'Aim: generic WMI calls
    'return value of BIOS
    On Error Resume Next
    Dim colItems,objItem
    Dim objWMI
    Const strService = "winmgmts:{impersonationlevel=impersonate}//" 'binding to WMI
    Const strComputer = "." 'this machine
    Set objWMI = GetObject(strService & strComputer & strNamespace) 'GLOBAL wmi
    Set colItems = objWMI.ExecQuery(strQuery,,lFlags)
    For Each objItem In colItems
    If Err Then
    StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "WMI query: " & strQuery & " in " & strNamespace & objItem.Name
    Call ErrHandler("WMI error " & strQuery,1)
    Else
    WMI=objItem.Name 'Return value
    End If
    Next
    End Function
    Function fGetModelName(strWQLPCInfo)
    'Aim: Get model name from BIOS - WMI field sometimes varies if laptop, so try two
    'Return STRING: Model string from BIOS or "UNKNOWN" if null
    On Error Resume Next
    Dim colPCInfo,objPCItem
    Dim strModel
    Set colPCInfo = GetObject("winmgmts:").ExecQuery(strWQLPCInfo,"WQL",lFlags)
    If Err Then
    Call ErrHandler("fGetModelName: Error querying WMI " & strWQLPCInfo,2)
    Else
    For Each objPCItem In colPCInfo
    If Not IsNull(objPCItem.Model) Then
    strModel=objPCItem.Model
    ' iRAM=objPCItem.TotalPhysicalMemory
    Else
    If (strHTAVendor=cApprovedOEM And IsLaptop = True) Then ' resort to HP specific query for older laptops
    'Notebook
    strModel=QueryHPBIOS(sNoteModel)
    if strModel="" then strModel=QueryHPBIOS(sModel) 'try alt value
    Else
    strModel=QueryHPBIOS(sModel)
    End If
    End If
    Next
    End If
    If strModel = "" Then
    fGetModelName = "UNKNOWN"
    Model.style.visibility="hidden"
    Else
    fGetModelName=strModel
    End If
    End Function
    '====================================================
    '====================================================
    Function fGetRAM(strQuery)
    'Aim: get RAM installed. NB Win32_ComputerSystem::TotalPhysicalMemory may not be accurate
    'Return integer
    On Error Resume Next 'equiv to Err.Clear
    Dim colItems, item
    Dim iTotalMemory
    Set colItems = GetObject("winmgmts:").ExecQuery(strQuery,"WQL",lFlags)
    If Err Then
    Call ErrHandler("fGetRAM: Error querying " & strQuery,2)
    Else
    iTotalMemory = 0
    For Each item In colItems
    iTotalMemory = iTotalMemory + CDBL(item.Capacity)/(1024^2)
    Next
    End If
    If iTotalMemory = "" Then
    fGetRAM = "RAM UNKNOWN"
    RAM.style.visibility="hidden"
    Else
    fGetRAM=iTotalMemory
    End If
    End Function
    '====================================================
    '====================================================
    Function fGetCPUInfo(strQuery)
    'Aim: query WMI for CPU info - number and number of cores
    'Return: function=CPU count, var for the cores: iCPUCoreCount, strHTAArchitecture, strCPUDesc
    On Error Resume Next
    Dim colItems, objItem
    Dim NumberOfProcessors
    Set colItems = GetObject("winmgmts:").ExecQuery(strQuery,"WQL",lFlags)
    If Err Then
    Call ErrHandler("GetCPUInfo: Error querying " & strQuery,2)
    Else
    For Each objItem In colItems
    If Err Then
    Else
    If Not IsNull(objItem.NumberOfCores) Then
    NumberOfProcessors = Trim(objItem.NumberOfCores) 'NumberOfProcessors
    End If
    If Not IsNull(objItem.NumberOfLogicalProcessors) Then
    iCPUCoreCount = Int(Trim(objItem.NumberOfLogicalProcessors))
    End If
    If Not IsNull(objItem.DataWidth) Then
    strHTAArchitecture=Trim(objItem.DataWidth) & "-bit"
    End If
    If Not IsNull(objItem.description) Then
    strCPUDesc = Trim(objItem.description) 'cpu name
    End If
    End If
    Next
    If NumberOfProcessors = "" Then
    NumberOfProcessors = "UNKNOWN"
    End If
    fGetCPUInfo = Int(NumberOfProcessors)
    ' iCPUCoreCount = Int(NumberOfLogicalProcessors)
    End If
    End Function
    '====================================================
    '====================================================
    Function fGetComputerSystemProdIDNumber(strWQLID)
    'Aim: Get UUID from Win32_ComputerSystemProduct
    'Return: great big integer
    Dim colSys,objSys
    Dim strUUID
    On Error resume next
    Set colSys = GetObject("winmgmts:").ExecQuery(strWQLID,"WQL",lFlags)
    If Err then
    Call ErrHandler("fGetComputerSystemProdIDNumber: Error querying " & strWQLID,2)
    Else
    For Each objSys In colSys
    If Not IsNull(objSys.IdentifyingNumber) Then
    strUUID = Trim(objSys.IdentifyingNumber)
    End If
    Next
    If strUUID = "" Then
    fGetComputerSystemProdIDNumber = "UNKNOWN"
    Else
    fGetComputerSystemProdIDNumber = strUUID
    End If
    End If
    End Function
    '=================================================================================
    '=================================================================================
    Function fGetDrives(strQuery)
    Dim colDisks,objHDD
    Dim strDriveType, strDiskSize, strDisk
    Dim strDiskFSType
    Dim iGBUnits
    On Error Resume Next
    iGBUnits=1073741824
    Dim iRAW
    iRAW=0
    Set colDisks = GetObject("winmgmts:").ExecQuery(strQuery)
    For Each objHDD In colDisks
    Select Case objHDD.DriveType
    Case 1 strDriveType = "Drive could not be determined."
    Case 2 strDriveType = "Removable Drive"
    Case 3 strDriveType = "Local hard disk."
    Case 4 strDriveType = "Network disk."
    Case 5 strDriveType = "Compact disk (CD)"
    Case 6 strDriveType = "RAM disk."
    Case Else strDriveType = "Drive type Problem."
    End Select
    strDiskFSType = objHDD.FileSystem
    'Find C
    If objHDD.Name="C:" Then
    If isNull(objHDD.FreeSpace) Then
    If blnDebug=True then Call ErrHandler("ALERT!! Volume " & objHDD.Name & "is RAW",1) 'Abort/clean
    fCheckDrives="ALERT!! Volume " & objHDD.Name & "is RAW"
    End If
    End If
    strDiskSize = Int(objHDD.Size /iGBUnits) & "GB" 'calc size of disk
    strDisk = strDisk & VbCrLf & "Vol " & objHDD.Name & " (" & strDriveType & ") size: " & strDiskSize & " (free: " & Int(objHDD.FreeSpace /iGBUnits) & "GB), " & strDiskFSType
    fGetDrives=strDisk
    Next
    If (Err.Number <>0) Then
    Call ErrHandler("WMI Property Query Error: [" & Err.Number & "]",2)
    fGetDrives = -1
    Exit Function
    End If
    End Function
    '=================================================================================
    '=================================================================================
    Function fUniversalCheckData(varData,strStage) 'template
    'Aim: Check value passed...
    'is not blank
    'is in range x..y
    'spelt OK
    'is in a list
    'format is text, numeric
    'return: string: the original value
    On Error Resume Next
    Dim Err
    if blnDebug Then StatusBar.InnerText = StatusBar.InnerText & VbCrLf & "Validating " & strStage & " data..."
    If Err Then
    Call ErrHandler("WARNING: Error discovering value in " & strStage,2) '1=Quit,2=Warn
    strHTAModel="Unknown"
    Else
    Select Case varData
    Case IsEmpty(varData) Or IsNull(varData)
    Call ErrHandler("WARNING: Error in "& strStage,2) '1=Quit,2=Warn
    fUniversalCheckData="Unknown"
    Case IsNumeric(varData)
    If varData<0 Then
    Call ErrHandler("WARNING: Value negative"& strStage,2) '1=Quit,2=Warn
    fUniversalCheckData="Unknown"
    End if
    ' & varData &
    Case IsDate(varData)
    Case Else
    fUniversalCheckData=varData 'Data OK - return value unchanged
    End Select
    End If
    End Function
    '=================================================================================
    'Checks - follow if true DO, if false warn/abort
    '=================================================================================
    Function fCheckBattery(strQuery)
    'Aim: Find if battery is running
    'Return pass/fail
    On Error Resume Next 'equiv to Err.Clear
    Const wbemFlagReturnImmediately = &h10
    Const wbemFlagForwardOnly = &h20
    Dim colItems, item
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\WMI")
    Set colItems = objWMIService.ExecQuery("SELECT * FROM BatteryStatus Where Voltage > 0", "WQL", _
    wbemFlagReturnImmediately + wbemFlagForwardOnly)
    For Each item In colItems
    if objItem.PowerOnline = True Then
    strHTABattery=objItem.PowerOnline
    strHTABatteryState = cFail
    Err.Raise 9010,"fCheckBattery",strHTABattery & " Laptop running on battery. OSD Cannot continue."
    Call ErrHandler(ucase(strHTABatteryState) & ": " & Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",1)
    StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "FATAL ERROR - Laptop on Battery. Please plug into an outlet before proceeding."
    iTimer = window.setTimeout("Abort", iAbortTimeout, "VBScript")
    Else
    strHTABatteryState = cPassed
    End if
    Next
    fCheckBattery=strHTABattery
    End Function
    '====================================================
    Function fCheckProcess(strQuery)
    'Aim: Find if outlook is running
    'Return pass/fail
    On Error Resume Next 'equiv to Err.Clear
    Dim colItems, item
    Set colItems = GetObject("winmgmts:").ExecQuery(strQuery,"WQL",lFlags)
    For Each item In colItems
    if item.Name = "OUTLOOK.EXE" Then
    strHTAOutlook=item.Name
    strHTAOutlookState = cFail
    Err.Raise 9010,"fCheckOutlook",strHTAOutlook & " running. OSD Cannot continue."
    Call ErrHandler(ucase(strHTAOutlookState) & ": " & Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",1)
    StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "FATAL ERROR - Outlook Running, please close outlook before proceeding."
    iTimer = window.setTimeout("Abort", iAbortTimeout, "VBScript")
    Elseif item.Name = "communicator.exe" Then
    strHTAOutlook=item.Name
    strHTAOutlookState = cFail
    Err.Raise 9010,"fCheckOutlook",strHTAOutlook & " running. OSD Cannot continue."
    Call ErrHandler(ucase(strHTAOutlookState) & ": " & Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",1)
    StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "FATAL ERROR - Communicator Running, please close OCS before proceeding."
    iTimer = window.setTimeout("Abort", iAbortTimeout, "VBScript")
    Else
    strHTAOutlookState = cPassed
    End if
    Next
    fCheckProcess=strHTAOutlook
    End Function
    '====================================================
    '1 - Make
    Function fCheckVendor(strVendor)
    'Aim: Check make is one the OS/build is designed For
    'Return: STRINGS for "Make", BIOS version and BIOS date (generic): strHTAVendorState pass or fail
    On Error Resume Next
    Dim colItems,objItem
    Set colItems = GetObject("winmgmts:").ExecQuery(strVendor, "WQL", lFlags)
    For Each objItem In colItems
    strHTAVendor=objItem.Manufacturer
    if objApprovedMakesDict.exists(strHTAVendor) then
    strBIOSver=objItem.SMBIOSBIOSVersion
    strBIOSDate=Mid( objItem.ReleaseDate, 5, 2 ) & "/" & Mid( objItem.ReleaseDate, 7, 2 ) & "/" & Left( objItem.ReleaseDate, 4 )
    strHTAVendorState=cPassed
    Else
    strHTAVendorState=cFail
    Err.Raise 9010,"fCheckVendor",strHTAVendor & " found. The build will not work on this make of hardware"
    Call ErrHandler(ucase(strHTAVendorState) & ": " & Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",1)
    bAbortBuild=True
    end if
    Next
    fCheckVendor=strHTAVendor
    End Function
    '=================================================================================
    '=================================================================================
    '2 - Models check
    Function fCheckModel(strThisModel)
    'Aim Check target machine is in list of models
    'Return string
    On Error Resume Next
    StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "Checking model..." & VbCrLf
    If objModelsDict.exists(trim(strThisModel)) then ' if current model in objDict then huzzah
    strHTAModelState=cPassed
    StatusBar.InnerText=StatusBar.InnerText & vbTab & "Model detected: " & vbTab & strHTAModelState
    Else
    strHTAModelState=cFail
    Err.Raise 9010,"fCheckModel",strThisModel & " found. The build will not work on this model of hardware"
    Call ErrHandler(ucase(strHTAModelState) & ": " & Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",1)
    end if
    fCheckModel=strHTAModel
    End Function
    '=================================================================================
    '=================================================================================
    '3 - RAM
    Function fCheckRAM(strRAM)
    'Aim: Check installed RAM > x
    'Return string digits with units, e.g. 4GB
    'use strHTARAM for value
    '==================================================================
    ' Memory Preflight Check (from MDT2012)
    '==================================================================
    On Error Resume Next
    StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "Checking RAM..."
    If Err.Number <> 0 Then
    Call ErrHandler("Error occurred while calculating computer's memory.",2)
    End If
    fCheckRAM = Int(strRAM/1024) & "GB" 'format in GB
    If Int(strRAM) > cMinimumMemoryMB Then
    strHTARAMState=cPassed 'Sufficient memory - show whole number in GB"
    StatusBar.InnerText=StatusBar.InnerText & vbTab & "RAM installed: " & vbTab & strHTARAMState
    Else
    strHTARAMState=cFail
    Err.Raise 9030 ,"fCheckRAM","Not enough memory in this machine!" & " Required physical memory is: " & cMinimumMemoryMB & " MB."
    Call ErrHandler(ucase(strHTARAMState) & ": " & Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",1) 'abort build
    End If
    End Function
    '=================================================================================
    '=================================================================================
    '4 - NTFS disk
    Function fCheckNTFS(strDiskFS)
    'Aim: Check HDD is NTFS
    'Return string
    On Error Resume Next
    StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "Checking file system is not RAW..."
    If Instr(1,strDiskFS,cMinFS,VBTextCompare)<>0 Then
    fCheckNTFS=cMinFS 'disk format is OK (NTFS)
    StatusBar.InnerText=StatusBar.InnerText & vbTab & " File system: " & cPassed
    Else
    fCheckNTFS=cFail
    Err.Raise 9040 ,"fCheckNTFS","WARNING: Disk not correct file-system. Type required is: " & cMinFS & "." & VbCrLf & _
    "The deployment will fail unless you reformat the target disk immediately."
    Call ErrHandler(Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",2) 'halt build
    End If
    End Function
    '====================================================
    '=================================================================================
    '5 - CPU checks
    '=================================================================================
    Function fCheckCPUSpeed(strCPU) 'any HW
    'Aim: Check CPU speed
    'Return string = number + appropriate units, e.g. 5HGz (strCPU)
    On Error Resume Next
    StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "Checking CPU spec..."
    Select Case Right(strCPU,3) 'check units
    Case "MHz"
    strCPU=Left(strCPU,4)/1000 'reformat to GHz
    Case "GHz"
    strCPU=strCPU 'unit already OK
    Case Else
    Call ErrHandler("CPU units are unknown",2)
    End Select
    'Check clock speed
    If Int(Left(trim(strCPU),1))>=iMinCPUSpeed Then
    fCheckCPUSpeed=strHTACPUSpeed 'CPU is fine i.e don't change value
    StatusBar.InnerText=StatusBar.InnerText & vbTab & "CPU Speed: " & cPassed
    Else
    fCheckCPUSpeed=cFail 'already in GHz
    Err.Raise 9050,"fCheckCPUSpeed","CPU speed pre-requisite failed. Minimum processor clock speed is: " & iMinCPUSpeed
    Call ErrHandler(Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",1) 'halt build
    End If
    End Function
    '=================================================================================
    '=================================================================================
    Function fCheckCPUArch(strCPUArch) 'any HW
    'Aim: Check CPU width
    'Return string
    On Error Resume Next
    StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "Checking CPU bus width..."
    'Check clock speed
    If Int(Left(trim(strCPUArch),2))>=iMinCPUArch Then
    fCheckCPUArch=strHTAArchitecture 'CPU is fine i.e don't change value
    StatusBar.InnerText=StatusBar.InnerText & vbTab & "CPU width: " & cPassed
    Else
    fCheckCPUArch=cFail 'already in GHz
    Err.Raise 9052,"fCheckCPUArch","CPU width pre-requisite failed. Minimum processor width required is: " & iMinCPUArch
    Call ErrHandler(Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",1) 'abort build
    End If
    End Function
    '=================================================================================
    Function fCheckCores(iCores)
    'Aim: Check hardware (CPU) has a minimum number of cores
    'Return Integer
    On Error Resume Next
    StatusBar.InnerText=StatusBar.InnerText & VbCrLf & "Checking CPU cores..."
    If iCores>=iMinCores Then
    fCheckCores=iCores
    StatusBar.InnerText=StatusBar.InnerText & vbTab & "Core count: " & vbTab & cPassed
    'StatusBar.InnerText=StatusBar.InnerText & vbTab & "CPU cores: " & cPassed
    Else
    fCheckCores=cFail
    Err.Raise 9051,"fCheckCores","WARNING: Not enough cores on the CPU to support the build. Minimum CPU cores is: " & iMinCores
    Call ErrHandler(Err.Description & " (Code: " & Err.Number & " - " & Err.Source & ")",2) 'halt build
    End If
    End Function
    '=================================================================================
    '=================================================================================
    Function fCheckHPCPUSpeed 'HP ONLY
    'Aim: Check CPU speed
    'return: string
    'Check CPU speed
    On Error Resume Next
    strWQLCPU = "processor speed"
    strTemp=QueryHPBIOS(strWQLCPU,"")
    Select Case Right(strTemp,3)
    Case "MHz"
    strTemp=Left(strTemp,4)/1000 'reformat to GHz
    Case "GHz"
    strTemp 'is OK
    Case Else
    Call ErrHandler("CPU is unknown",2)
    End Select
    'Check clock speed
    If strTemp>=iMinCPUSpeed Then
    fCheckCPUSpeed= strTemp & "GHz"
    Else
    Err.Raise 9050,,"CPU speed pre-requisite failed"
    Call ErrHandler("CPU is too slow",1)
    fCheckCPUSpeed=cFail 'already in GHz
    End If
    End Function
    '=================================================================================
    '=================================================================================
    Function fGetModels
    'Aim: Read external text file
    'return: dictionary object - models as key, integer as value e.g. Dell Optiplex,12
    'On Error Resume Next
    Dim objFSO
    Dim objFile
    Dim strFile
    Dim strEntry
    Dim n
    Dim strfilepath
    Dim iLineCount 'count lines to avoid listing first item with ,.
    Set objModelsDict = CreateObject("Scripting.Dictionary")
    set objFSO=CreateObject("Scripting.FileSystemObject")
    Const ForReading=1
    strfilepath = Left(window.location.pathname,InStrRev(window.location.pathname,"\"))
    strFile=strfilepath & "Models.txt"
    set objFile=objFSO.OpenTextFile(strFile,ForReading)
    iLineCount=0
    'read in each line of data until you reach the end of the file
    do While objFile.AtEndOfStream<>True
    strEntry=objFile.ReadLine
    'you can now do what ever you want with the line as referenced with the strEntry variable such as
    'echoing it back (e.g. wscript.Echo strEntry) or passing it as a variable to a function of subroutine (e.g. MyFunction strEntry)
    objModelsDict.comparemode=VBTextCompare
    objModelsDict.Add strEntry,iLineCount
    iLineCount=iLineCount+1
    If blnDebug then
    If iLineCount=1 Then
    StatusBar.InnerText=trim(strEntry)
    Else
    StatusBar.InnerText=StatusBar.InnerText & ", " & trim(strEntry) 'list models
    End If
    End If
    Loop
    objFile.Close
    End Function
    '=================================================================================
    '=================================================================================
    '====================================================
    Function ErrHandler(strErrorMsg,iErrMode)
    'Aim: to handle error states
    ' 1 = Abort
    ' 2 = Warn
    'Return 'Appropriate text message explaining the error
    '====================================================
    Const msgTitle="SCCM Deployment Preflight Checklist"
    'On Error Resume Next '< don't use that as we want to KEEP the error properties
    'Abort=1
    If iErrMode=1 Then
    StatusBar.InnerText=strErrorMsg 'overwrite status with Error message
    ' StatusBar.InnerText=StatusBar.InnerText & VbCrLf & " " & strHTAOutlook & " " & strHTAVendor & " " & strHTAVendorState & _
    ' VbCrLf & " " & strHTAModel & strHTAModelState & _
    ' VbCrLf & " " & strHTARAM & strHTARAMState & _
    ' VbCrLf & " " & strHTAHDD & strHTAHDDState
    iTimer = window.setTimeout("Abort", iAbortTimeout, "VBScript") 'Abort (close) after n seconds
    'MsgBox strErrorMsg,vbExclamation,msgTitle
    'ErrBar.class=""
    ElseIf iErrMode=2 Then
    'Warning
    StatusBar.InnerText=StatusBar.InnerText & VbCrLf & strErrorMsg & " " '& "(" & Err.Description & " :" & Err.Number & ")"',vbExclamation,msgTitle
    Err.Clear
    End If
    End Function
    '====================================================
    Sub Abort
    'Aim: Quit gracefully
    window.close()
    End Sub
    </script>
    <!-- #region BODY -->
    <body>
    <br />
    <div>
    <span style="version"> <span id="VersionSpan"></span></div>
    <div style="text-align: center;">
    <H1 style="font-family: Arial, Helvetica, sans-serif; font-size: large; text-align: center; color: #000000; text-transform: capitalize">System information</H1>
    <span>
    <table border="1" cellspacing="0" cellpadding="0" style="width: 912px"
    id="SysInfoTable">
    <tr class="h1">
    <td align="right" class="Header1" style="width: 76px; height: 18px">
    </td>
    <td align="right" class="Header1" style="height: 18px"><em id="VendorCaption">Vendor</em></td>
    <td align="left" class="style2" style="height: 18px"><span id="Vendor"></span></td>
    <td align="right" class="Header2" style="height: 18px"><em id="ModelCaption">Model</em></td>
    <td align="center" class="style4" style="width: 400px; height: 18px"><span id="Model"></span></td>
    </tr>
    <tr>
    <td align="right" class="Header1" style="width: 76px">
    </td>
    <td align="right" class="Header1"><em id="ProductCaption">Product ID</em></td>
    <td align="left" class="style2"><span id="Product"></span></td>
    <td align="right" class="Header2"><em id="RAMCaption">Memory(in MB)</em></td>
    <td align="left" class="style4" style="width: 400px"><span id="RAM"></span></td>
    </tr>`
    <tr>
    <td align="right" class="Header1" style="width: 76px">
    </td>
    <td align="right" class="Header1"><em id="CPUCaption">CPU speed (in GHz)</em></td>
    <td align="left" class="style2"><span id="CPUspeed"></span></td>
    <td align="right" class="Header2"><em id="CPUInfoCaption">No: CPU\Cores</em></td>
    <td align="left" class="style4" style="width: 400px"><span id="CPUInfo"></span></td>
    </tr>
    <tr>
    <td align="right" class="Header1" style="width: 76px">
    </td>
    <td align="right" class="Header1"><em id="DiskFSCaption">Filesystem info</em></td>
    <td align="left" class="style2"><span id="HDDFS"></span></td>
    <td align="right" class="Header2"><em id="CapableArchCaption">Architecture</em></td>
    <td align="left" class="style4" style="width: 400px"><span id="CapableArchitecture"></span></td>
    </tr>
    <tr>
    <td align="right" class="Header1" style="width: 76px">
    </td>
    <td align="right" class="Header1"><em id="BIOSVerCaption">BIOS version</em></td>
    <td align="left" class="style2" ><span id="BIOSVERSION"></span></td>
    <td align="right" class="Header2"><em id="BIOSDateCaption">BIOS Date</em></td>
    <td align="left" class="style4" style="width: 400px"><span id="BIOSDate"></span></td>
    </tr>
    </table>
    </span>
    </div>
    <div class="StatusBar">
    <br />
    <Span id="StatusBar">Loading...please wait.</Span>
    </div> <br><br>
    <div align="center">
    <input type="button" name="btnStop" id="btnStop" value="Continue" onclick="Abort">
    <input type="Button" value="Re-Scan Machine" name="button1" onClick="Window_Onload" class="button">
    </div>
    </body><!-- #endregion -->
    </html>

  • Find strings in a list using startsWith?

    Hi I hope someone can help me with this problem. Before I start, my apologies as I am a student still trying to learn Java and have got to the murky ground of data structures.To help me better understand this I tried a sample program (which surprisingly was working fine til now ha). So I have a list of songs by various artists added to a tree which begins with the singers name. I want to be able to isolate songs by a particular artist but have tried loads of different ways of doing it to no avail. I tried creating a new list but couldn't add my songs to it. I then found the remove() method and thought why not just find what I want and remove the rest from the list I can always recreate my list again after. So I think I'm close with my code and that's it's maybe a casting issue??
    String song = songTree.getElement(currentNode);
    List<String> list = MyCollection.getSongs(song);
    // List newList = new ArrayList();
    String check = new String("Pearl Jam");
    Iterator myIter = list.iterator();
    while (myIter.hasNext()){
    if (myIter.next().!startsWith(check)){
    // newList.add();
    else{
    list.remove();
    Edited by: jojololo on Nov 9, 2009 11:35 AM

    jojololo wrote:
    Before I start, my apologies as I am a student still trying to learn Java and have got to the murky ground of data structures.No need to apologize, as long as you are clear in your communication. Why would we be here except to help? (Well okay, to amuse ourselves...)
    To help me better understand this I tried a sample program (which surprisingly was working fine til now ha). So I have a list of songs by various artists added to a tree which begins with the singers name. I want to be able to isolate songs by a particular artist but have tried loads of different ways of doing it to no avail. I tried creating a new list but couldn't add my songs to it. Why not? What happened when you tried? This is probably the right way and should definitely work, so let's isolate the problem there.
    I then found the remove() method and thought why not just find what I want and remove the rest from the list I can always recreate my list again after.Nah that doesn't seem like a reasonable idea. Let's go back to creating a new collection to hold your isolated subset.
    Post an SSCCE of your atte this stagempt at using a new list, and tell us where it goes wrong and what you expect it to do instead. Be sure to use the CODE button in the editor to format your code.
    Sorry didn't really answer your questions very well with my post;
    I've tried so much at this stage I don't even remember what went wrong. basically in the try I posted just now the startsWith method is not recognised. I'm aware that I'm trying to compare an object reference to a string but thought I had dealt with that with my casting? I think my subset would be saved here in the new collection but again I'm missing something in the comparisment. Oh sometimes I feel like packing in the java! We do far too much theory and nowhere near enough actual coding.
    import java.util.*;
    public class Test {
        public static void main(String[] args){
            List variousArtists = new ArrayList();
            // Some intentionally doubled to ensure only one gets put on the tree later           
            variousArtists.add("Pearl Jam - Even Flow");
            variousArtists.add("U2 - The End Of The World");
            variousArtists.add("The Smashing Pumpkins - Spaceboy");
            variousArtists.add("Pearl Jam - Alive");
            variousArtists.add("The Smashing Pumpkins - Quiet");
            variousArtists.add("Pearl Jam - Black");
            variousArtists.add("U2 - The End Of The World");
            variousArtists.add("Radiohead - Street Spirit");
            variousArtists.add("U2 - One");
            variousArtists.add("Radiohead - Street Spirit");
            variousArtists.add("Radiohead - Street Spirit");
            variousArtists.add("The Smashing Pumpkins - Mayonaise");
            variousArtists.add("U2 - Mysterious Ways");
            variousArtists.add("The Smashing Pumpkins - Hummer");
            variousArtists.add("Pearl Jam - Even Flow");
            variousArtists.add("The Smashing Pumpkins - Disarm");
            variousArtists.add("U2 - One");
            variousArtists.add("The Smashing Pumpkins - Quiet");
            variousArtists.add("The Smashing Pumpkins - Mayonaise");
            variousArtists.add("Pearl Jam - Black");
            variousArtists.add("The Smashing Pumpkins - Mayonaise");
            variousArtists.add("Pearl Jam - Even Flow");
            variousArtists.add("Radiohead - Street Spirit");
            variousArtists.add("U2 - The End Of The World");
            List newList = new ArrayList();
            String check = new String("Pearl Jam");
            String search;
            Iterator myIter = variousArtists.iterator();
                  while (myIter.hasNext()){
         search = (String) myIter.next();
               if (myIter.next().startsWith(check)){
                     newList.add(myIter);
    }   

  • Html check box pass more than one value into bean

    Hi all'
    I have group of check box in html , I need to pass more than one value
    into bean an ddisplay in jsp
    what do i do wrong
    private Vector select =new Vector();
      private String mybox =null;
      public download() {
         again(); 
      /* Accessor Methods */
    private void addmybox(String name){
        select.addElement(name);}
    public void setMybox(String name) {
         mybox = name;
    public String[] getMybox() {
         String[] s = new String[select.size()];
         select.copyInto(s);
         return s;
            in my htmli have <%
         String[] mybox= format.getMybox();
         for (int i=0; i<Mybox.length; i++) {
             <%= format.getMybox%>
    %>
    i got error at <%= format.getMybox[i]%>

    Hi ram,
    thank you, I don't have ideal in my mide .
    in my jsp I have
    <td>  <input type=checkbox name=mybox value=<%= link.getNewNum()%>></td>in my servlet I have something like
    String[] checked = request.getParameterValues("mybox");
            try {
            conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433","A#$","RE@89");
            conn.setCatalog("sequences");  
          stmt = conn.createStatement();  
           for(int i=0; i<checked.length; i++){
                   String select=checked;
    String Sql=" select NewNum, Name, Length, Segment, Sequence";
    Sql+=" from Sec04";
    Sql+=" where NewNum='"+select+"'";
    Sql+=" union";
    Sql+=" select NewNum, Name, Length, Segment, Sequence";
    Sql+=" from MySec";
    Sql+=" where NewNum='"+select+"'";
    Sql+=" union";
    Sql+=" select NewNum, Name, Length, Segment, Sequence";
    Sql+=" from Sec03";
    Sql+=" where NewNum='"+select+"'";
    Sql+=" union";
    Sql+=" select NewNum, Name, Length, Segment, Sequence";
    Sql+=" from Sec02";
    Sql+=" where NewNum='"+select+"'";
    Sql+=" union";
    Sql+=" select NewNum, Name, Length, Segment, Sequence";
    Sql+=" from Sec01";
    Sql+=" where NewNum='"+select+"'";
    rs = stmt.executeQuery (Sql);
    while(rs.next()) {              
    String Name = rs.getString("Name");
    String Segment =rs.getString("Segment");
    String Length = rs.getString("Length");
    String Sequence = storeSequenceData(rs.getString("Sequence"));
    String SContent = Name + " ," Segment ", "+ Length + "\n" +Sequence  ;
    now I want
    String SContent = Name + " ," +Segment + ", "+ Length +  "\n" +Sequence  +"\n" + Name+"Segment+","+length+"+"\n" +Name......untill the end
    it sees like I need to look st on shipp car. is that right??
    Thank you !!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Query string error in JSP

    Hi. I originally thought my problem was a javaScript problem but now realize it is a JSP problem:
    I have a JSP calling another JSP (which is opened in a smaller window with javaScript) and it uses a query string for values. One of these variables in the string is a note the user enters and can contain anything. Problem is when they enter text with the '&' symbol, I'm getting a Null Pointer Execption as the receiving JSP interprets it as part of the query string.
    How can I 'hide' these characters so the receiving JSP page doesn't try to process it?
    Thanks in advance,
    Mike

    hi,
    you could detect the string before you sent the string, check for the & symbol and replace it with something else, such as the html equivalent and then append it to the url and send it, on the other end read it and replace the symbol with the & to get it back without confusing the code. you would run into the same problems if the user enter = or possibly ? into the string, so try fixing it with a search and replace method.

  • HELP: String to double conversion?

    Hello,
    I want to convert a String to a double, and then use this double for a calculation. The conversion seems to be ok, but I get an error with the calculation... Please HELP!
    A part of my code:
    double angle;
    Double converted_angle;
    angle=jTextField2.getText();
    converted_angle= Double.valueOf(angle);
    double theta = cos(Math.PI/180*converted_angle);
    ERROR: "operator * cannot be applied to double,java.lang.Double"
    Thanks in advance.

    This is happening because you want to multiply a Double object, instead of a double value. Do this:
    Double converted_angle; should be double converted_angle;
    converted_angle= Double.valueOf(angle); should be changed to converted_angle = Double.parseDouble(angle);
    angle should probably be a String.
    check this link for your options:
    http://java.sun.com/j2se/1.4/docs/api/java/lang/Double.html

  • Calculation of  container check digit

    Dearest All.
    i hv a requirement .. i hv to calculate check digit for Conatiners for Export and Import.
    i tried a lot  but failed.....
    the logic is as follow...
    Every container-number needs its own check digit. This check digit is the last figure of the container-number, that behind the -.
    Of course, you can calculate this check digit yourself.
    First start with the prefix.     Then there is the number itself.
    This is the simplest part of the calculation.     Last but not least the calculation:
    with an example: OOLU 708695.
    Each letter of the prefix has its own value:
    A     10     J     20     S     30
    B     12     K     21     T     31
    C     13     L     23     U     32
    D     14     M     24     V     34
    E     15     N     25     W     35
    F     16     O     26     X     36
    G     17     P     27     Y     37
    H     18     Q     28     Z     38
    I     19     R     29           
    Each figure of the number has its own value.
    1     1
    2     2
    3     3
    4     4
    5     5
    6     6
    7     7
    8     8
    9     9
    0     0
    We know that:     Now calculate:
    O     26     26 X 1 =     26
    O     26     26 X 2 =     52
    L     23     23 X 4 =     92
    U     32     32 X 8 =     256
    7     7     7 X 16 =     112
    0     0     0 X 32 =     0
    8     8     8 X 64 =     512
    6     6     6 X 128 =     768
    9     9     9 X 256 =     2304
    5     5     5 X 512 =     2560
         Total =     6682
    Of course we can understand if you don't want to calculate all these check digits by hand.
    Therefore we made you a little tool.
    Enter the container-number as followed: XXXX123456, just try it.
    Container-number:
         Check digit:     
         Calculate the check digit           Clear the form
    Now divide this total by 11:
    6682 / 11 = 607,4545
    and take the figures after the comma
    and multiply it by 11 to get the check digit.
    0,4545 X 11 = 5
    The complete container-number is:
    OOLU 708695-5

    HEY ,
    don't get panic
      you can do this 
      go step by step 
      if you are aware of Dialog programing  then you can do this
      OR  if you want to do in simple  basic report then also it is possible  just use your logic  .
    1)   create one  module pool  
    2)   create  one  screen   
       in screen give  one button  to get EVENT in  PAI 
      in PAI  you can write code 
      now for 
    albhabets and  there numbers you can ceate either one ztable  or you can create one internal table  with cloumn
    albhabet , value 
    A              20
    B              30
    etc
    also same for
    1 ,1
    2,2
    3,3
    etc
    when user will enter  this number  say  OOLT 78432
    use spilt function to split the entered string   into two string 
    check the length of BOTH string 
    using DESCRIBE  FUNCTION 
    NOW UP TO THAT LENGTH 
    IF LENGHT OF 1ST STRING IS  4
    AND LENGTH OF SECOND IS 5
    THEN
    for 1st character  check with  albhabet value 
    get 1st value  and multiply with 1
    get 2nd and multiply with  2 .
    get 3rd and multy with 4 .
    and so on  .
    same for  numbers 
    you can do and 
    use you logic for  other steps
    you can do that  .
    just go step by step how you have explained .
    Regards
    Deepak.
    Edited by: Deepak Dhamat on Oct 9, 2010 8:53 AM

  • Compairing a string to multiple strings

    This is what I need to accomplish in seudocode
    if (string != "this" or "that" or "this" or "that")
    Id do it with 12 different or statements
    if(string != "this" || string != "that" || ...etc){}but Im wondering if there is a cleaner way to go about this.

    String bla = "String4";
    String[] checks = { "String1", "String2", "String3", ... };
    boolean match = false;
    for (int i = 0; i < checks.length; i++) {
      if (checks.equals(bla)) {
    match = true;
    break;
    if (match) {
    Message was edited by:
    Simeon
    Message was edited by:
    Simeon

  • Beginner : Array , String Problems continue.

    Hi everybody I am so New in Java or rather not really able to understand Java yet.
    I have assignment where I do not know how to think anymore..is probably very easy to those who understand programming but sadly I do not.
    Program should do:
    1. assign any amount of different strings.
    2. user is giving any letter he/she wants and program to find it among given strings.
    If searched letter is in any string/ strings , only these strings or string are printed.
    3. If in given strings is not searched letter, program has to say it, for ex: there is not letter you search for.
    As long as now I have only, strings assigning to array. So there are strings in array but I do not know how to write code where I can find given letter by user.
    I just do not know how I should think(anymore at all ;)) here. I am really frustrated and desperate, how to understand this?? Once and for all!!!
    I was thinking maybe I should use ArrayList? but how...or Can it be done both ways with Array or with ArrayList?
         public static void main(String[] args) {
              Scanner scan = new Scanner(System.in);
              System.out.print("How many strings ?");
              int antal= scan.nextInt();
              String [] str = new String[antal];
               String string = null;     
              int x;
               scan.nextLine();
                 for( x=0;x<str.length;x++){
                      System.out.print("String "+(x+1)+": ");                       
                 string= scan.nextLine();
                 str[x]= string;
                System.out.print("Write a letter you wish to find :");
                String letter = scan.nextLine();
                char check = letter.charAt(0);
      //somthing in here ....

    Thank you very, very much for helping me, this is the first forum where I am getting any answers at all. Thanks guys!
    Yes, that is true I have a problem to "see" things in code..I feel " lost in translation " :)...Sometimes I think I understand code and than suddenly code does total different thing than I thought. I have to pass 2 exams of Java basic and bit advance level of Java , all seems very dark now..but I have a hope that I at least pass those exams. Of course it could be fantastic to start understand Java (or any other computer language) and be able to code one day for real. To be honest, I envy you that you can understand Java. When, all code works is so cool and fun! ok, Back to code...
    So I read your tips and advices , thanks.
    Here is another problem, with help of indexOf(char) I got index for character I searched, fine.
    The way i wrote the code I got separate answer for each string(check in code). What I need to have is, separate printed strings where given character is found and nothing else should be printed. Later, I need just one general comment ,only in case if character is NOT found in given strings.
    import java.util.*;
    public class upp9 {
         public static void main(String[] args) {
              Scanner scan = new Scanner(System.in);
              System.out.print("How many strings ?");
              int antal= scan.nextInt();
              String [] str = new String[antal];
              int x;
               scan.nextLine();
                 for( x=0;x<str.length;x++){
                      System.out.print("String "+(x+1)+": ");                       
                 str[x]= scan.nextLine();
                System.out.print("Write a letter you wish to find :");
                String letter = scan.nextLine();
                char check = letter.charAt(0);
                   for( x=0;x<str.length;x++){
                       str[x].indexOf(check);
                     //     System.out.println("String "+(x+1)+" "+str[x].indexOf(check));
                if((str[x].indexOf(check))>=0)
                     System.out.println("String "+(x+1)+" "+str[x]);
                else
                     System.out.println("Nothing in this string");
      System.out.println();
    }is printed.
    How many strings ?4
    String 1: hello
    String 2: other
    String 3: alex
    String 4: batman
    Write a letter you wish to find :a
    Nothing in this string
    Nothing in this string
    String 3 alex
    String 4 batmanI should get printed (with other code)...where I don't know how to think here? what code I should use?, what I can what I can not do here...hmmm
    //in case found
    How many strings ?4
    String 1: hello
    String 2: other
    String 3: alex
    String 4: batman
    Write a letter you wish to find :a
    String 3 alex
    String 4 batmanor....
    //in case NOT found
    How many strings ?4
    String 1: hello
    String 2: other
    String 3: alex
    String 4: batman
    Write a letter you wish to find : j
    Not found

  • Can't check for nulls in a conditional?

    Hey everyone. Trying my hand at a text based game but I'm encountering many problems:
    I have this method in one class that (as you can see) has a conditional that checks to see if 'check' is null, this throws a null pointer exception whenever it is called.
    private void placeChars()
            String check = currentItem.getItemString();
            if(check.equals(null) && currentRoom.getShortDescription().equals("in the cafeteria"))
                josh.getSentence(0);
        }Here is the method that it is calling from:
    public String getItemString()
            String returnString = null;
            if(haveItems != 0 ){
            returnString = "Items:";
            Set<String> keys = items.keySet();
            for(String item : keys) {
                returnString += " " + item;
        return returnString;
        }I'm not sure what I am doing wrong here :/ and yes I know the code is extremely ugly :)

    if check is null, you can't invoke any methods on it, including equals.
    To check for null:
    if (check == null)

  • HTTPService and string value.

    We are having an unexpected issue in our application. One of
    the tags returned by a HTTPService is:
    <lot_code>7E00024</lot_code>
    And we bind this to a data grid column using:
    <mx:DataGridColumn headerText="Lot Number"
    dataField="lot_code"/>
    But the value displayed is:
    7e+24
    So Flex is automatically converting it to a number and
    showing in exponential format. How do we define the XML so we force
    a value to be "string" or "text"?
    Thanks in advance.

    Hi
    How are you receiving your data?
    as E4X, XML, OBJECT?
    That is important, because for instance if it comes like xml
    you can use a tostring() to get a node like a string, check de
    documentation about XML on adobe livedocs

Maybe you are looking for

  • BDC for FF67 not displaying the line itmes of second page

    Hi all, I am using the Z BDC report Manual Bank Statement Upload (FF67). The BDC is as mentioned below : We are using start variant in the BDC. The report is working fine but the issue is that suppose if their are 45 line items and on one page we can

  • How do I get my music of my ipod on to a new computer if the original computer is dead

    My Itunes account with all my music from cd's was on a computer that died. How do I get my new computer to import all the songs and be the primary computer? I deauthorized all, but everytime I connect one of my ipods or ipads it tells me its synced t

  • Standard Preview size/quality Lightroom 1.1. (how and what)

    I'm working on a Macbook pro, with hi-res 17" screen 1920x1200. In most manuals, tutorials etc. it says that you can "set the standard preview size fitting for your screen". I'm looking for some more background info on the standard preview, to decide

  • Joining three tables

    I have to join three tables but i m getting error as given below: Error i m getting- Syntax error(missing operator) in query expression 'invoice.INVOICE_NO=inv_ent_main.INVOICE_NO INNER JOIN invrate ON invrate.INVOICE_NO=inv_ent_main.INVOICE_N'. My Q

  • Local Bonjour Gateway display

    Firstly, let me tell you about the setup. SSID for clients and SSID for Apple TV devices common across all buildings in the campus. Uses 802.1x for clients and PSK for Apple TV devices. Interface group for the SSID uses multiple vlans for the SSID, s