Problem with retrieving correct Task ID

Discuss RoboTask here
Post Reply
nurv
Posts: 1
Joined: Wed Apr 30, 2025 1:37 pm

Problem with retrieving correct Task ID

Post by nurv »

Hello,

I’m having trouble retrieving the correct Task ID. For example, I have a task with the External Name “Task 9”, and its Task ID is 303E887B. However, when I display the {TaskID} variable, it shows 809404539, which is incorrect. {TaskExtName} correctly returns “Task 9”, but {GetTaskIdByExtName({TaskExtName})} also returns the wrong value: 809404539.

In another task, {TaskID} even returns a negative number.

How can I reliably get the correct Task ID (the one that looks like 303E887B)? This is very important for my project.

Thank you very much for your help!
Oleg
Site Admin
Posts: 3201
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Problem with retrieving correct Task ID

Post by Oleg »

Task ID is an integer value
809404539 - in decimal format
303E887B - in HEX format

809404539 (dec) equals to 303E887B (hex). You can check it in system calculator.

To convert decimal value to hex format use hex() function of VB script

Also look at the example below.

To convert the HEX format to decimal, just place the "&H" characters in front of the HEX value. (see step #4 of example)

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|307868550
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1573"
Hide=INTEGER|0
ID=INTEGER|-741371817
LogOnAsUser=INTEGER|1
Name=STRING|"Task ID example (v2)"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RestrictRESTAPIAccess=INTEGER|0
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""_dec"" with value ""{TaskID}"""
Params=FOLDER

[Actions\Action1\Params]
_rt_variables_produced=STRING|"_dec"
expand=STRING|"1"
linecount=STRING|"1"
varname=STRING|"_dec"
varvalue=STRING|"{TaskID}"

[Actions\Action2]
ActionID=STRING|"A_SCRIPT_VBEVALUATE"
Enabled=INTEGER|-1
Name=STRING|"VB Evaluate"
Params=FOLDER

[Actions\Action2\Params]
_rt_variables_produced=STRING|"_hex"
expression=STRING|"hex({_dec})"
linecount=STRING|"0"
loadfromfile=STRING|"1"
variable=STRING|"_hex"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""decimal = {_dec}"""
Params=FOLDER

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"decimal = {_dec}"
msg1=STRING|"hex = {_hex}"
msg2=STRING|"ext name(1) = {GetTaskExtNameById({_dec})}"
msg3=STRING|"ext name(2) = {GetTaskExtNameById(${_hex})}"
msg5=STRING|"GetTaskExtNameById = {GetTaskExtNameById({TaskId})}"
msgcount=STRING|"6"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_SCRIPT_VBEVALUATE"
Enabled=INTEGER|-1
Name=STRING|"VB Evaluate"
Params=FOLDER

[Actions\Action4\Params]
_rt_variables_produced=STRING|"_dec2"
expression=STRING|"&H{_hex}"
linecount=STRING|"0"
loadfromfile=STRING|"1"
variable=STRING|"_dec2"

[Actions\Action5]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""decimal from hex = {_dec2}"""
Params=FOLDER

[Actions\Action5\Params]
icon=STRING|"1"
msg0=STRING|"decimal from hex = {_dec2}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"
Oleg Yershov
Post Reply