# How to assign a value to a variable manually?

**URL:** <https://root-forum.cern.ch/t/how-to-assign-a-value-to-a-variable-manually/34884>\
**Category:** Newbie\
**Created:** [June 27, 2019, 4:55pm UTC](https://root-forum.cern.ch/t/how-to-assign-a-value-to-a-variable-manually/34884 "2019-06-27T16:55:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrc1104](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/a5b964/32.png) [@mrc1104](https://root-forum.cern.ch/u/mrc1104)\
**Post date:** [June 27, 2019, 4:55pm UTC](https://root-forum.cern.ch/t/how-to-assign-a-value-to-a-variable-manually/34884/1 "2019-06-27T16:55:41Z")

</div>

I am using Form() to allow me to manually select which files I want to load.  
ie:  
void main(Int\_t Hist1){

TFile::Open(Form(“ThisFile\_%d”,Hist1));

}

I have to scale the data in each file by a file dependent factor. Can I use Form() to do this?

I was trying to do:

void main(Int\_t File1, Double\_t Scalar){  
TFile::Open(Form(“ThisFile\_%d”,File1));  
Double\_t x = Form("%f",Scalar);  
}  
but this returns an error that it cannot assign Int to a rvalue of char\*? (Idk what the error means).

Any advice?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [June 27, 2019, 5:06pm UTC](https://root-forum.cern.ch/t/how-to-assign-a-value-to-a-variable-manually/34884/2 "2019-06-27T17:06:43Z")

</div>

```auto
Double_t x = Scalar;

```

---

<div class="post-metadata">

**Author:** ![mrc1104](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/a5b964/32.png) [@mrc1104](https://root-forum.cern.ch/u/mrc1104)\
**Post date:** [June 27, 2019, 6:34pm UTC](https://root-forum.cern.ch/t/how-to-assign-a-value-to-a-variable-manually/34884/3 "2019-06-27T18:34:35Z")

</div>

That was a lot easier than I thought it would be. Thanks!
