Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to convert character array to integer? 1

Status
Not open for further replies.

ArmenD

Programmer
Feb 3, 2005
101
US
how to convert character array to integer in f77?
 
Use the read statement
Code:
character*64 str
integer i
str = '12345'
read (str, '(I5)') i
 
hi,
the problem is that I am using JAPI so I am actually getting the number from a textfield. the textfield does not have a get_value() option, and so i need to write a conversion function preferably from a String to int.
or char to int since that's next best thing.
 
It is quite limited. You can also use the keylistener to restrict the keys that the user types but you'll probably have to handle the I/O and display as well.

Normally easier to get the project going then worry about non-numeric input if there is time. It is one of those things that can get you really bogged down. Took me 2 days to do it in Basic on a Commodore PET - the number of variations of numeric input is quite staggering, especially when you start including floating point formats and negative numbers.
 
hi,
so how can i get an integer from a text field.
how do i convert a string to integer?
 
Code:
character*64 str
integer i, field
...
! declare a field
field = j_textfield (frame)
...
! get the value
call j_gettext (field, str)
read (str, '(I5)') i
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top