Text

Just starting out? Need help? Post your questions and find answers here.
dannyboy99
User
User
Posts: 27
Joined: Sun Jul 13, 2008 9:47 am
Location: UK

Text

Post by dannyboy99 »

I have a text input, but I only want to have text (not numbers) entered.

Is there a way of telling betwwen the two please.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

OK ugly code... but it should work... not at my compiler for an hour...

Code: Select all

temp$ = INPUT$
ROFL = len(temp$)
OK = 0

for X = 0 to ROFL
   lookat = Asc(Mid(temp$,rofl,1))
        if lookat > 65
            OK = 1
        endif
next

if OK = 1
   ; input good!
else
    ; BAD INPUT
endif
:D
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

Any numbers at all or just a number instead of text?

Is "I'm 10 years old" a no no? There may be a shortcut with val()

Rooks code will be heaps faster with pointers :P whenever I see Asc(Mid()) alarms go off in my head :D

I vaguely recall that there is some subclassing method to apply filters or something too but I suck at that so I can't post any code :?
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

I absolutely cannot do pointers in my head... need working compiler to test my insanity! :wink:
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

I can relate to that, I certainly wouldn't post pointer code without testing..

you win :P
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

You are assuming of course that he want's an input checked after it has been input, what he might be asking for is stopping numbers being input into a stringgadget() on the fly.

Maybe we need some more info before we start coding up examples.
dannyboy99
User
User
Posts: 27
Joined: Sun Jul 13, 2008 9:47 am
Location: UK

Thanks

Post by dannyboy99 »

Thanks for your work on this one

As the last poster says, I was using several textgadget to input data, but of only 4 numbers. and one box could only contain text.

While I am here, does anyone know how to use setfiledate

I have a load of files that I wanted to alter the creation dates so my mp3 player will play them in the order I want - its for amateur drama.

does anyone have an example of how to do this.


Thanks
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Thanks

Post by Demivec »

dannyboy99 wrote:Thanks for your work on this one

As the last poster says, I was using several textgadget to input data, but of only 4 numbers. and one box could only contain text.

While I am here, does anyone know how to use setfiledate

I have a load of files that I wanted to alter the creation dates so my mp3 player will play them in the order I want - its for amateur drama.

does anyone have an example of how to do this.


Thanks
Here's an example that loops through files listed in an array and sets the date by adding sequential day values to an arbitrary start date:

Code: Select all

startDate.l = ParseDate("%yy/%mm/%dd", "02/12/01") ;pick your start date

numberOfSongs.l = 30 
For sequenceNumber = 1 to numberOfSongs
  songFile.s = songFilenameArray.s(sequenceNumber) ;a sample entry in the songFilenameArray would look like "C:\Song.mp3"
  SetFileDate(songFile, #PB_Date_Created ,AddDate(startDate, #PB_Date_Day, sequenceNumber.l))
Next 
dannyboy99
User
User
Posts: 27
Joined: Sun Jul 13, 2008 9:47 am
Location: UK

Problem

Post by dannyboy99 »

I tried this, but I get an error message saying

song.s() is not a function (or not available in demo mode)

And should songs.s be the directory where all the sound effects are stored.

Knowing me, I have done something wrong, but I an not sure what.

Thanks

Dan
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Problem

Post by Demivec »

dannyboy99 wrote:I tried this, but I get an error message saying

song.s() is not a function (or not available in demo mode)

And should songs.s be the directory where all the sound effects are stored.

Knowing me, I have done something wrong, but I an not sure what.

Thanks

Dan
I didn't supply a complete code example, I had thought that you only lacked an understandng on the use of SetFileDate(). You can add this on to the beginning of the code sample I gave previously. You'll still need to tailor the code with information regarding your songs.

Code: Select all

#numberOfSongs = 30

DataSection
songList:
  Data.s "C:\Song.mp3","C:\Song2.mp3" ;add each song, 30 total
EndDataSection

Dim songFilenameArray.s(#numberOfSongs)

Restore songList
For i.l = 1 To #numberOfSongs
  Read songFilenameArray(i)
Next
dannyboy99
User
User
Posts: 27
Joined: Sun Jul 13, 2008 9:47 am
Location: UK

Thanks

Post by dannyboy99 »

Thanks very much for those who helped me here especially Demivec

I have finsihed the programs, which seem to working well.

Thanks again

Danny

ps One thing I found was that i could alter the dates of the files, great, but when i copied them it used todays date as creation date.

Is this something the PB does
Post Reply