Jump to content











Photo
- - - - -

grub4dos new <whitespace>;;<whitespace> operator


  • Please log in to reply
5 replies to this topic

#1 steve6375

steve6375

    Platinum Member

  • Developer
  • 7188 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 19 March 2013 - 10:19 AM

chenall has added a new operator to grub4dos latest version

 

as you know we had && and ||   but these did not always work as expected and they were conditional.

This made it tricky if you just wanted to execute a series of commands on one line regardless of the result or even test the result immediately on the same line

 

e.g.

 

try (on an older grub4dos version)

 

set hh=1 && if "%hh%"=="1" echo %hh%

this does not echo 1 to the command line, even though hh is set to 1 when you type the 'set' command afterwards.

 

However now we have an unconditional operator <single-whitespace-char>;;<single-whitespace-char>

 

so now these work as expected:

 

set hh=1 ;; echo %hh%

 

iftitle [uuid (hd0,0) ;; set UUID=%?_UUID% ;; if "%UUID%"=="028B-3924"] test my UUID
reboot
set H=0 ;; hiddenflag (hd0,0) && set H=1 ;; echo HIDDEN=%h%
Note that the  last line is equivalent to
set H=0
hiddenflag (hd0,0) && set H=1
echo HIDDEN=%h%

 

and so always returns   'HIDDEN=0' or 'HIDDEN=1'
 
 
To test if grub4dos supports the ;; operator use the single line:
set g4new=1 ;; set g4new=2 && call if not "%^g4new%"=="2" echo ERROR: This old grub4dos version does not support the ;; operator! && pause

 

note we need to use call and need to insert a ^ character into the %g4new% variable to stop it being translated too early by the call function!
 
or chenall's version check which is even better!

set g4new=1 ;; echo supported! && if not "%g4new%"=="1" echo Error: this grub4dos version does not support the ";;" operation!

 

 

  • ilko likes this

#2 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 15185 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 19 March 2013 - 10:51 AM

I guess that the definition is concatenate operator, allowing more commands on the same line, i.e. the direct correspondent to the batch single ampersand "&".

 

We can imagine this as being the same as a CR+LF separator, that processes the command and epands variables, but allowing to keep commands on the same line and thus allowing the use of multiple commands inside conditional structures such as

 

 

iftitle [<boolean condition>] Title text shown if true

 

Good to know :).

 

:cheers:

Wonko



#3 steve6375

steve6375

    Platinum Member

  • Developer
  • 7188 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 26 March 2013 - 11:00 PM

I just realised that the ;; operator also allows us to have in-line comments!
 
e.g.
 
map /fred.iso (0xff) ;; # this maps fred.iso to the device 255
map --hook ;; # this hooks the interrupt
 
 
Actually no, after further testing - it gives an Error 27: unrecognised command error!  


#4 steve6375

steve6375

    Platinum Member

  • Developer
  • 7188 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 28 March 2013 - 02:20 PM

chenall has fixed this issue now in a new version. (fixed link!)

 

So we can have inline comments using

 

some command ;; # this is a comment which is ignored!

:clap: 



#5 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 15185 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 28 March 2013 - 02:34 PM

chenall has fixed this issue now in a new version.

...for which you just posted an invalid link ... :whistling:

 

 

 

 

400. That’s an error.

Your client has issued a malformed or illegal request. That’s all we know.

 

 

Let's wait until the feature is inserted in one of the "normal" builds available here:

http://code.google.c.../downloads/list

 

:cheers:

Wonko



#6 steve6375

steve6375

    Platinum Member

  • Developer
  • 7188 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 31 March 2013 - 10:43 AM

FYI:

chenall has now added the &; and |; operators

 

set a=1 && echo %a%       - does not echo 1 to the console

but

set a=1 &; echo %a%        - does echo 1 to the console

 

so, together with ;;  we can have single lines with embedded comments like

 

set a=1 ;; # variable a is used for xxx ;; set b=2 ;; # variable b is used for yyy ;; if "%a%"=="%b%" echo they match! |; echo they don't match

 

or

 

uuid () > nul ;; set UUID=%?% ;; echo UUID is %UUID% ;; # get the UUID of the current drive

 

 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users