Ask Experts Questions for FREE Help !
Ask
    InfoJunkie4Life's Avatar
    InfoJunkie4Life Posts: 1,409, Reputation: 81
    Ultra Member
     
    #1

    Feb 21, 2014, 06:21 PM
    Does anyone know anything about batch scripting?
    I'm working on a complex script; it employs nothing more than native commands for NT 5.2 and newer for compatibility purposes. I have a function within it that seems to be misbehaving and freezing up. Ideally it would be called "call :csvEdit "query:searchString" | "append:appendString"

    The append section functions perfectly.

    The query Does not. It is supposed to search each line of the file and list any line with a number to choose one that matches the query. The search string would then be parsed by a different function within the script to load the information into environmental variables. The output is environmental %csvOut%.

    Code:
    :csvDB :: "query:searchString" OR "append:appendString" (query will return the whole line or 0 for no match | appendstring will return 1/0 success/fail)
    setlocal enabledelayedexpansion enableextensions
    set netRoot=c:\users\Timothy\Desktop
    set "str2=%1"
        if not x%str2:query=% == x%str2% goto :query
        if not x%str2:append=% == x%str2% goto :append
        if 1 == 1 (
            set output=error
            goto :333
            )
        :append
            for /f "usebackq tokens=2 delims=:" %%a in ('%str2%') do (
                echo %%a >> %netRoot%\customers.csv
                if %errorlevel% == 0 set output=1
                if %errorlevel% NEQ 0 set output=0
                )
        goto :333
        :query
            set /a "n=0"
            for /f "usebackq tokens=2 delims=:" %%A in ('%str2%') do (
                for /f "usebackq tokens=* delims=," %%a in (`findstr /I /C:%%A %netRoot%\customers.csv`) do (
                    set /a "n+=1"
                    echo !n! %%a %%b %%c %%d %%e %%f %%g %%h %%i
                    set "arr[!n!]=%%a,%%b,%%c,%%d,%%e,%%f,%%g,%%h,%%i"
                    )
                if !n! == 0 set "output=0" & goto :333 & echo Not Found
                echo Choose the correct database entry
                set /p choice=Enter 0 for Not Present
                if !choice! == 0 set output=0 & goto :333
                )
            set output="%arr[!choice!]%"
            goto :333
    :333
    (endlocal
        set "csvOut=%output%"
    )
    goto eof

Check out some similar questions!

Scripting [ 3 Answers ]

I am getting scripting errors all the time, nearly on every web page with a popup that I have to answer "Do you want to continue running scripts?". I always check no but it comes back soon or on the next web page. I use both IE 9 and Firefox 13 and get these errors in both browsers. I have found...

I need to automate my batch file , passing the username and password in the batch fil [ 5 Answers ]

I need to automate my batch file , passing the username and password in the batch file itself so that, user doesn't have to put in the authentication every time for windows.

Html Scripting Help [ 5 Answers ]

I'm new to HTML scripting and I had a question to ask. Is it possible to say.. after a time make a script change to a different script? EX: Mondays this script runs, Tuesday this part of the script runs, etc etc A time based trigger (not just days but also say.. certain times of days. Don't even...

Action scripting [ 1 Answers ]

hello sir! I want to ask that question about random numbers.I know how to generate random nos but I don't know how to save that number example: like that I show u below: :confused:// command: trace(Math.floor(Math.random()*10)); some no. appears on the screen like 4 I want to save that no above...

How to useShell scripting ? [ 1 Answers ]

Hai every buddy, I would like to know about scripting... I am trying to figure it out for a long time... Call any buddy help me Thanking you Bibu Bharathan


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.