Xml 在FroG GUI中传递带有空格的Windows批处理变量?

Xml 在FroG GUI中传递带有空格的Windows批处理变量?,xml,user-interface,batch-file,command-line,window,Xml,User Interface,Batch File,Command Line,Window,帮助您基于XML为Windows批处理(.bat)文件构建GUI 例如,设置三个变量并打印到文本文件,因此.bat如下所示: @echo off &setlocal setlocal EnableDelayedExpansion set var1=%1 shift set var2=%1 shift set var3=%1 echo %var1% %var2% %var3%> test.txt <form caption="test GUI" program="tes

帮助您基于XML为Windows批处理(.bat)文件构建GUI

例如,设置三个变量并打印到文本文件,因此.bat如下所示:

@echo off &setlocal

setlocal EnableDelayedExpansion

set var1=%1
shift
set var2=%1
shift
set var3=%1

echo %var1% %var2% %var3%> test.txt
<form caption="test GUI" program="test.bat" icon="" showconsole="false" width="514" url="" description="" author="">
    <control type="tabset">
        <tabsheet caption="General" active="true">
            <control type="groupbox" caption=" Basic info " fontstyle="bold">
                <control type="edit" caption=" Variable 1 " commandline="" width="100"/>
                <control type="edit" caption=" Variable 2 " commandline="" width="100"/>
                <control type="edit" caption=" Variable 3 " commandline="" width="100"/>
            </control>
        </tabsheet>
    </control>
</form >
set var1=%1
set var2=%2
set var3=%3
(据我所知,您必须通过
shift
才能让FroG赶上变量?我无法以任何其他方式让它工作,我从FroG上构建的某个示例中获取了此信息)

GUI代码如下所示:

@echo off &setlocal

setlocal EnableDelayedExpansion

set var1=%1
shift
set var2=%1
shift
set var3=%1

echo %var1% %var2% %var3%> test.txt
<form caption="test GUI" program="test.bat" icon="" showconsole="false" width="514" url="" description="" author="">
    <control type="tabset">
        <tabsheet caption="General" active="true">
            <control type="groupbox" caption=" Basic info " fontstyle="bold">
                <control type="edit" caption=" Variable 1 " commandline="" width="100"/>
                <control type="edit" caption=" Variable 2 " commandline="" width="100"/>
                <control type="edit" caption=" Variable 3 " commandline="" width="100"/>
            </control>
        </tabsheet>
    </control>
</form >
set var1=%1
set var2=%2
set var3=%3
同样的问题仍然存在,打印在cli或文件中。如果变量不在GUI的引号中,它会跳过最后一个字符串,但如果变量在GUI中,它也会打印引号


TLDR:需要在GUI中传递带引号的字符串(因为字符串中有空格),但不能打印引号。

我已经测试过了,没有问题,只需使用下面的示例

test.cmd

@Echo关闭
设置“var1=%~1”
设置“var2=%~2”
设置“var3=%~3”
如果“%~3”==”退出/B
(Echo=%var1%%var2%%var3%)>“test.txt”
测试前端


屏幕截图

one two three four

test.txt

one two three four

你好但看起来您仍然需要手动将变量3括起来?就因为它有空间。因此,每次字符串在任何字段中有空格时,您都必须手动添加引号,相当贫民区,但它现在可以工作。如果它有空格,那么字符串
four
将是不同的变量,
variable 4
,即
%4
;双引号将其定义为单个参数!但是,如果GUI中有三个字段,今天是一个带5个空格的字符串,明天是一个带7个空格的字符串,那么最好使用一个变量来覆盖批处理文件中的所有参数,
Set“varAll=%*”
。或者创建一个包含多个输入项的前端,比如说12个,只需填写您需要的输入项,然后在批处理文件中将最后一行更改为
>“test.txt”Echo%var1%%var2%%var3%%var4%%var5%%var6%%var7%%var8%%var9%%var10%%var11%%var12%