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.

callsub error

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-07-2009, 08:57 PM
Newbie
 
Join Date: Dec 2008
Posts: 5
Default callsub error

Can you help me solving this error?

Callsub ("recherch",val(i),m)
Error description
Length cannot be less than zero.
Parameter name : Length.

BR - Serge
Reply With Quote
  #2 (permalink)  
Old 03-07-2009, 09:15 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Have you declared val() ?

What value does i have ?

Do you have some more code to look at ?

Best regards.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #3 (permalink)  
Old 03-08-2009, 06:51 PM
Newbie
 
Join Date: Dec 2008
Posts: 5
Default Callsub

Quote:
Originally Posted by klaus View Post
Have you declared val() ?

What value does i have ?

Do you have some more code to look at ?

Best regards.
THIS IS THE CODE, thanks for your kind help.
Enter this nr in textbox1 : 10324197
then click OK
then chose anything from COMBOBOX1
the error occurs at that moment.

BR
Serge
Reply With Quote
  #4 (permalink)  
Old 03-08-2009, 07:00 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

I'm sorry if I'm annoying but it will be much easier to test your code if you'll compress your files to one zip.
Reply With Quote
  #5 (permalink)  
Old 03-08-2009, 07:55 PM
Newbie
 
Join Date: Dec 2008
Posts: 5
Default callsub

Quote:
Originally Posted by Erel View Post
I'm sorry if I'm annoying but it will be much easier to test your code if you'll compress your files to one zip.
Sorry, this is the zipped files :

BR
Serge
Reply With Quote
  #6 (permalink)  
Old 03-08-2009, 08:25 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

I had a look at your code:

1) The "Recherch" routine is not finished ! There is no End Sub line
Code:
<font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">FileClose</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> (c1)</font></font>
</font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">FileClose</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> (buf)</font></font>
</font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">FileCopy</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> (</font></font></font></font><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000">"Datab.txt"</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">, </font></font></font></font><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000">"Data.txt"</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">)</font></font>
</font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">End</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> Recherch </font></font>
</font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Msgbox</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">(</font></font></font></font><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000">"269"</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">) </font></font>
<font size=
"2"><font face="Courier New">nonTrouv�:</font></font>
<font size=
"2"><font face="Courier New">textbox2.Text = </font></font></font></font><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000">"NON TROUVE"</font></font></font>
</font></font></font></font></font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">FileClose</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> (c1)</font></font>
</font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">FileClose</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> (buf)</font></font></font></font>
What is End Recherch supposed to do ?

2) You call Recherch with CallSub ("Recherch",val(i),m)
but your variables are global variables, you don't need to transfer those in the calling line , just Recherch is enough to call the routine, like?
Code:
<font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Sub </font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">ComboBox1_SelectionChanged (Index, Value)</font></font>
<font size=
"2"><font face="Courier New">  i = </font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">0</font></font></font>
</font></font></font></font></font></font><font face=
"Courier New"><font size="2"><font face="Courier New"><font size="2">  val(i) = value</font></font>
<font size=
"2"><font face="Courier New">  m=</font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">2</font></font></font>
</font></font></font></font></font></font><font face=
"Courier New"><font size="2"><font face="Courier New"><font size="2">  Recherch</font></font>
</font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">  Msgbox</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">(</font></font></font></font><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000"><font face="Courier New"><font size="2"><font color="#800000">"SSS"</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">)</font></font>
</font></font><font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">End Sub</font></font></font></font></font></font></font></font></font>
3) In routine Button1_Click you use following line:
Code:
<font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">If</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> sentence = </font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">EOF </font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Then </font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Goto</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> nonTrouv�</font></font></font></font>
You try to jump outsides the routines, this is NOT allowed in Basic4PPC.

4) Following code
Code:
  <font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">If</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> mots(</font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">0</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">)= Textbox1.Text </font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Then </font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Goto</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> MAJ </font></font></font></font><font face="Courier New"><font size="2"><font color="#008000"><font face="Courier New"><font size="2"><font color="#008000"><font face="Courier New"><font size="2"><font color="#008000">'Else Msgbox ("non trouv�")</font></font></font>
</font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Loop</font></font></font>
</font></font></font></font></font></font>
<font size=
"2"><font face="Courier New"><font size="2"><font face="Courier New">MAJ:</font></font></font></font>
can be replaced by:
Code:
  <font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">If</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2"> mots(</font></font></font></font><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080"><font face="Courier New"><font size="2"><font color="#800080">0</font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font face="Courier New"><font size="2">)= Textbox1.Text </font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Then </font></font></font></font></font></font></font></font></font><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Exit</font></font></font></font></font></font></font></font></font>
<font face=
"Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff"><font face="Courier New"><font size="2"><font color="#0000ff">Loop</font></font></font></font></font></font></font></font></font>
Try to make the changes suggested above and post the new version and we can look at it again.

Are you 'translating' the code from another basic ?

Best regards.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide

Last edited by klaus : 03-08-2009 at 08:38 PM.
Reply With Quote
  #7 (permalink)  
Old 03-09-2009, 09:56 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

I had a second look at your program.

Attached a modifyed version, I have shortened the code.
- replaced all your ComboBox filling routines by just one.
- deleted a lot of none necessary variables used for the ComboBox filling
- replaced the ComboBoxX_SelectionChanged routines by one.

As I don't know exactly what you want to do I made some assumptions.
- I am not shure if you really need the array val(100), a single variable would probably do it.
- in the ComboBox_SelectionChanged is m = i + 1 or could it be different
-- if yes m = i + 1 is OK
-- otherwise you must use the Select / case structure

If you have any questions about these changes don't hesitate to ask.

Best regards.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #8 (permalink)  
Old 03-10-2009, 10:11 PM
Newbie
 
Join Date: Dec 2008
Posts: 5
Default callsub

Many thanks for your kind help.
I will use your simplification in my original code.
I also found the line causing the error, wich is :
ligne = StrReplace (oldsentence,mots(m),val(i))

As I cannot find the cause of the error, I am looking for a turn around.
I have to read a line record of 13 words separated by commas (,) , change one of these words (the 3rd one for instance), then write the line record with the change to update the file.

In case you have an idea ....

Serge












Quote:
Originally Posted by klaus View Post
I had a second look at your program.

Attached a modifyed version, I have shortened the code.
- replaced all your ComboBox filling routines by just one.
- deleted a lot of none necessary variables used for the ComboBox filling
- replaced the ComboBoxX_SelectionChanged routines by one.

As I don't know exactly what you want to do I made some assumptions.
- I am not shure if you really need the array val(100), a single variable would probably do it.
- in the ComboBox_SelectionChanged is m = i + 1 or could it be different
-- if yes m = i + 1 is OK
-- otherwise you must use the Select / case structure

If you have any questions about these changes don't hesitate to ask.

Best regards.
Reply With Quote
  #9 (permalink)  
Old 03-11-2009, 08:01 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

The problem is that in the lines you have many ";" with nothing in between.
10324197;RES ALPINA II;Voice & Data RM LCE NEB-GSM;;;;;;;;;11;;;;;;;;

That means that, when you split your sentence into words, many words have nothing, in they are empty.
Then in your line ligne = StrReplace(oldsentence,words(m),val(i)) you try to serch for an empty word in the sentence, that's what the program doesn't like.

In the attached program you have a code that works:
- it is looking if words(m) is empty
- if yes it searches for the for the mth ";" and inserts the text there.
- if no it replaces the text.

The line you speak of is:
ligne = StrReplace(oldsentence,mots(m),val(i))

In the source code I have the line is
ligne = StrReplace(oldsentence,words(m),val(i))

In the Recherche routine you use both, in the second part of the routine do you want to use words(i) or mots(i) ?

Best regards.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
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


All times are GMT. The time now is 04:02 AM.


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