Sign in to follow this  
Followers 0
AutoitNew94

How to Correct this

7 posts in this topic

#1 ·  Posted (edited)

This does not work.

How do I fix this

#Include <String.au3>

$ParsedStr = _StringBetween($CmdLineRaw, "", " ")

If $ParsedStr[0] > 0 Then
    For $i = 1 To $ParsedStr[0]
        ConsoleWrite($ParsedStr[$i])
    Next
EndIf

Thank You-

Edited by AutoitNew94

"You're not smart enough for me to open my inbox, so stop sending me mail."

Share this post


Link to post
Share on other sites



This does not work.

#Include <String.au3>

$CmdStr = $CmdLineRaw

$ParsedStr = _StringBetween($CmdStr, "", " ")

If $ParsedStr[0] > 0 Then
    For $i = 1 To $ParsedStr[0]
        ConsoleWrite($ParsedStr[$i] & @LF)
    Next
EndIf

Thank You-

Here, try this

#Include <String.au3>

$CmdStr = $CmdLineRaw

$ParsedStr = StringSplit($CmdStr, " ")
If $ParsedStr[0] > 1 Then
    For $i = 1 To $ParsedStr[0]
        ConsoleWrite($ParsedStr[$i] & @LF)
    Next
EndIf

Is that what you were looking for?

Share this post


Link to post
Share on other sites

AutoitNew94,

I think it is doing exactly what I would expect when I put a space-delimited string as $CmdLineRaw. What do you expect it to do? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Here, try this

#Include <String.au3>

$CmdStr = $CmdLineRaw

$ParsedStr = StringSplit($CmdStr, " ")
If $ParsedStr[0] > 1 Then
    For $i = 1 To $ParsedStr[0]
        ConsoleWrite($ParsedStr[$i] & @LF)
    Next
EndIf

Is that what you were looking for?

No this does not work.

I get a compile error.


"You're not smart enough for me to open my inbox, so stop sending me mail."

Share this post


Link to post
Share on other sites

AutoitNew94,

I think it is doing exactly what I would expect when I put a space-delimited string as $CmdLineRaw. What do you expect it to do? :)

M23

I get no output to the command window.

I compile as console app I'm on x64 so I do

all that still no output.

My original script after compiled and ran from the command prompt

like.

C:\>MyScript.exe Hello World This is a Test

Produces not output.

:)


"You're not smart enough for me to open my inbox, so stop sending me mail."

Share this post


Link to post
Share on other sites

AutoitNew94,

I too get no output when I run it with a preset variable in SciTE or as a compiled exe with a real command line - and as I said earlier I would not expect to either. :P

Let me explain why:

Firstly you are asking _StringBetween to give you what is between the beginning of the file and a space, so you will only ever get the first parameter returned. :D

Secondly you have obviously not read the Help file about how _StringBetween returns its values. It does not return a count in the [0] element - that is the first return. So your loop never runs and you do not get even the first parameter to display on the console. :)

So how could you do it? Logty gave you the answer - use StringSplit. This runs for me in SciTE and (if I comment out the $CmdLineRaw declaration) as a compiled CUI with a set of parameters:

$CmdLineRaw = "1 2 3"

$ParsedStr = StringSplit($CmdLineRaw, " ")

If $ParsedStr[0] > 0 Then
    For $i = 1 To $ParsedStr[0]
        ConsoleWrite($ParsedStr[$i] & @CRLF)
    Next
EndIf

All clear? :)

M23

P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. ;)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thank you very much for your assistance on my question as well as proper format on the form.

With a little modification the code now does what I want it to.

$ParsedStr = StringSplit($CmdLineRaw, " ", 0)

If $ParsedStr[0] > 0 Then
    For $i = 1 To $ParsedStr[0]
        ConsoleWrite($ParsedStr[$i] & " ")
    Next
EndIf

Thank You-


"You're not smart enough for me to open my inbox, so stop sending me mail."

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0