Message: String formatting Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None String formatting 

Forum: User Requirements
Date: 01 May, 2010
From: Mathieu Trocmé <Mathieu Trocmé>

Hi there, 

One-line string formatting can be achieved using 'G4UIcommand::ConvertToString()', e.g.:
> G4String("foo_"+G4UIcommand::ConvertToString(myInt)+"_foo")
- no formatting 'à la sprintf' can be applied
- one has to include G4UIcommand.h in each file he wants to use ConvertToString
  (otherwise the following error message appears: "incomplete type `G4UIcommand' used in nested name specifier")

Could you please provide a Root-like Form(at) function: 
> G4String::Format("foo_%04d_foo",myInt)?
Other useful functions like Atof(), Atoi(), Chop(), First(char c), Last(char c), IsAlnum(), IsAlpha(), IsAscii(), IsDigit(), IsFloat(), ... could be useful.


 Add Message Add Message
to: "String formatting"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews

[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]