WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: deming on August 10, 2023, 09:22:34 AM

Title: How to parse AskTextBox input?
Post by: deming on August 10, 2023, 09:22:34 AM
I want to ask user for a list of numbers. Each row has 5 numbers, comma separated with @CR at end of each line. There are 100 or more lines. I can successfully parse the input into an array of 100 elements.  The problem is how to I now parse each line of the array into the 5 numbers?

; Prompt the user to enter a list of numbers n,n,n,n,n
; List will be 100 lines long
strInput = AskTextBox("Enter a list of numbers:", "Number List Input", "",0,0)

; Split the input string based on newlines to get each row
array = Arrayize(strInput,@LF)
arrRows = ArrInfo( array, 1)

; This DOESN'T work
; Loop through each row in the list of numbers
for j = 0 to arrRows
    ; Split each row based on the '-' delimiter to get individual values
    mystr = ""
    mystr = array(1)   ; ERROR HERE
    ParseData(mystr)
next
Title: Re: How to parse AskTextBox input?
Post by: td on August 10, 2023, 01:41:36 PM
Perhaps it would help to spend a little more time with the Consolidated Help File?

A few of the easily identifiable problems:

While there is nothing wrong with "Arrayizing" lists (I prefer arrays to item lists myself), you can also use the ItemList functions to accomplish the same tasks.