How to make a looping statement like this ?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
GMFAvionics
Posts: 2
Joined: 19 Mar 2015 04:13

How to make a looping statement like this ?

#1 Post by GMFAvionics » 19 Mar 2015 04:37

Hi,
I try to build a program using DOS script to interface a PC to a measuring equipment via GPIB port.

Here is the example script :
:gpib_abort
:buffer_488 SDB;AA;B01;CW;D0000;E2710;Z
:send_488 to rgs

Dxxxx,
D represents the start byte for TIME SETTING
xxxx represents the value of TIME SETTING
xxxx may contains hexadecimal number from 0000 to FFFF

I need a simple way to express these scenario :

:buffer_488 SDB;AA;B01;CW;D0000;E2710;F0000;G03E8;J10;V50;I0078;Z
:buffer_488 SDB;AA;B01;CW;D0001;E2710;F0000;G03E8;J10;V50;I0078;Z
:buffer_488 SDB;AA;B01;CW;D0002;E2710;F0000;G03E8;J10;V50;I0078;Z
----------------------------------up to-------------------------------------------
:buffer_488 SDB;AA;B01;CW;D9999;E2710;F0000;G03E8;J10;V50;I0078;Z

Anyone can help ?

jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: How to make a looping statement like this ?

#2 Post by jeb » 19 Mar 2015 07:14

HI GMFAvionics,

what you need?

You need a function that can convert a decimal value to it's hex representation.
Found at Dostips.com - Arithmetic

And then you need to build your line

Code: Select all

@echo off
setlocal EnableDelayedExpansion
call :toHex 100 hex
set "hex=!hex:~-4!"
set "lineHead=:buffer_488 SDB;AA;B01;CW;D"
set "lineTail=;E2710;Z"
set "line=!lineHead!!hex!!lineTail!"
echo !line!
exit /b

GMFAvionics
Posts: 2
Joined: 19 Mar 2015 04:13

Re: How to make a looping statement like this ?

#3 Post by GMFAvionics » 19 Mar 2015 21:05

Is it work for variable or string?
// can I use the new string in this function ??
:buffer_488 line // Is it correct ??

Post Reply