Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

One of my stupid questions....

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-26-2008, 07:14 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default One of my stupid questions....

Hi guys, it's been a while since i've ben active in the forum, code wise....
I'm stuck in a problem... I'm reading an ini file and have an eror label called "erro", wich gets called if there is any proble accesing the file...But how ca I call the errorlabel upon a condition?

This is my code...
Yes, I know i'm readding teh file 3 times before i use the data...
it's my way of doing things...bare with me on this one..

Code:
Sub LoadINI
ErrorLabel(erro)
FileOpen(c,
"LusiGES.ini",cRead)
a=FileRead(c)
a=FileRead(c)
a=FileRead(c)
Nome=StrRemove(a,
0,5)
'Here I want to test if the resulting string is equal to a known string (my own name), if not, then should be considered an invalid ini file, and jump to the error label.
If Nome<>"Paulo S�rgio Gomes" Then ' then what??? 

FileClose(c)
Erro:
Msgbox("N�o foi possivel ler" & crlf & "o ficheiro LusiGes.ini","Erro de Leitura.",cMsgBoxOK,cMsgBoxExclamation)

End Sub
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #2 (permalink)  
Old 01-26-2008, 07:17 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

You could use
Code:
If ... Then Goto Erro
Reply With Quote
  #3 (permalink)  
Old 01-26-2008, 07:23 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

I tryied that, it errors sayin the the variable erro is used before assigned a value..
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #4 (permalink)  
Old 01-26-2008, 07:27 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

I've tested it with this code and it doesn't give any error:
Code:
Sub LoadINI
ErrorLabel(erro)
FileOpen(c,
"LusiGES.ini",cRead)
a=FileRead(c)
a=FileRead(c)
a=FileRead(c)
Nome=StrRemove(a,
0,5)
'Here I want to test if the resulting string is equal to a known string (my own name), if not, then should be considered an invalid ini file, and jump to the error label.
If Nome<>"Paulo S�rgio Gomes" Then Goto Erro' then what??? 

FileClose(c)
Return
Erro:
Msgbox("N�o foi possivel ler" & crlf & "o ficheiro LusiGes.ini","Erro de Leitura.",cMsgBoxOK,cMsgBoxExclamation)

End Sub
Reply With Quote
  #5 (permalink)  
Old 01-26-2008, 07:30 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Sorry EREL, i'm too rusted....
I was typing "go to" instead of goto....it's working now...
Just one more "Stupid" question, to exit the sub before the error label gets executed.., I just tipe "exit", right?
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #6 (permalink)  
Old 01-26-2008, 07:36 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Not so stupid. More of a common mistake.
You should add Return before the error label.
Reply With Quote
  #7 (permalink)  
Old 01-26-2008, 07:45 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 2,344
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

I know it probably woul be a lot worse, mistake wise, but woudn't it be more logical an "ExitSub" keyword?
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)

My Posts helped you? Consider Buying me a Porto Glass!
Reply With Quote
  #8 (permalink)  
Old 01-27-2008, 10:26 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Cableguy View Post
woudn't it be more logical an "ExitSub" keyword?
Don't forget that Subs can return values so that "Return var" is quite logical.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Stupid question: Where is TreeView.dll? yildi Questions (Windows Mobile) 2 02-16-2008 03:19 PM
More SQL questions HARRY Questions (Windows Mobile) 2 01-04-2008 10:15 AM
SQL Questions tcgoh Questions (Windows Mobile) 7 12-31-2007 09:10 AM
Another "Stupid" question!!! Cableguy Questions (Windows Mobile) 2 06-28-2007 04:15 PM
maybe a stupid question,but... Cableguy Questions (Windows Mobile) 7 06-17-2007 10:44 PM


All times are GMT. The time now is 06:43 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0