Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #10606 > unrolled thread

Help on saving an array element to table

Started by"Jose F Zouain" <jfzouain@zetaconcepts.com>
First post2017-05-27 00:20 +0000
Last post2017-05-28 09:59 +0200
Articles 12 — 7 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  Help on saving an array element to table "Jose F Zouain" <jfzouain@zetaconcepts.com> - 2017-05-27 00:20 +0000
    Re: Help on saving an array element to table Sherlock <sherlock@sherlock.com.au> - 2017-05-27 00:07 -0700
      Re: Help on saving an array element to table Sherlock <sherlock@sherlock.com.au> - 2017-05-27 02:37 -0700
        Re: Help on saving an array element to table "Karl-Heinz" <invalid@invalid.invalid> - 2017-05-27 12:10 +0200
    Re: Help on saving an array element to table Franz Rachbauer <office@rachbauer.org> - 2017-05-27 09:28 +0200
    Re: Help on saving an array element to table Steve <steven_emmett@yahoo.co.uk> - 2017-05-27 00:36 -0700
    Re: Help on saving an array element to table Steve <steven_emmett@yahoo.co.uk> - 2017-05-27 00:53 -0700
      Re: Help on saving an array element to table "Jose F Zouain" <jfzouain@zetaconcepts.com> - 2017-05-28 00:54 +0000
        Re: Help on saving an array element to table JohnMartens <martens@tennishulp.info> - 2017-05-28 08:31 +0200
        Re: Help on saving an array element to table Mathias <mathias.hakansson@consultec.se> - 2017-05-30 00:28 -0700
          Re: Help on saving an array element to table "Jose F Zouain" <jfzouain@zetaconcepts.com> - 2017-05-31 11:42 +0000
    Re: Help on saving an array element to table [OT] "Karl-Heinz" <invalid@invalid.invalid> - 2017-05-28 09:59 +0200

#10606 — Help on saving an array element to table

From"Jose F Zouain" <jfzouain@zetaconcepts.com>
Date2017-05-27 00:20 +0000
SubjectHelp on saving an array element to table
Message-ID<eorv1vF5phcU1@mid.individual.net>
Hi Guys

I am still rusty, don't know why is giving me an error.

Have a multi-dimension array, all elements are string:

 aTranscod :={{"Purchase Order","PO"},;
 		{"Invoice","IN"},;
 		{"Return Sales","SR"},;
		{"Sales Order","SO"},;
 		{"Repair Order","RO"},;
 		{"Out Rental","RT"},;
 		{"In Rental","RI"}}


Already have the value in mememory for the first element of the 7
values in the array which is SELF:oDCTRANSCOD:TextValue

Now I want to save the second element to the table, this is what I am
doing and is giving me an error:


	LOCAL n AS DWORD
	n := AScan(aTranscod, SELF:oDCTRANSCOD:TextValue)

The ascan should return a value

Then want to save the second element of the value to the Table

SELF:oDBServer:FIELDPUT(#TRANSCOD, aTranscod[n,2])

I think I am scanning incorrent the array, the value in memory whic is
SELF:oDCTRANSCOD:TextValue, can be Purcase Order, Invoice, etc.

I did this and is giving me a compiled error:
n := AScan(aTranscod, {|aVal| aVal[2] = SELF:oDCTRANSCOD:TextValue})
Want to save for Sales Order, "SO" in #TRANSCOD	

Some help please, thanks

Jose

 
-- 

[toc] | [next] | [standalone]


#10607

FromSherlock <sherlock@sherlock.com.au>
Date2017-05-27 00:07 -0700
Message-ID<8a12c750-f4f4-495b-ab6e-5e1709b80436@googlegroups.com>
In reply to#10606
Jose

Easy make the field #TRANSCOD as type memo

{ "transdod", "M", 10, 0 }

Will work fine..

When reading back day aData := server:FIELDGET(#tranccod)
check that field contains an array

Like this, one way. 

LOCAL uValue AS USUAL
Local aData AS ARRAY

UValue := server:FIELDGET(#transcod)
if isArray(uValue)
   aData := Uvalue
endif

Phil McGuinness
---------------

On Saturday, May 27, 2017 at 10:20:17 AM UTC+10, Jose F Zouain wrote:
> Hi Guys
> 
> I am still rusty, don't know why is giving me an error.
> 
> Have a multi-dimension array, all elements are string:
> 
>  aTranscod :={{"Purchase Order","PO"},;
>  		{"Invoice","IN"},;
>  		{"Return Sales","SR"},;
> 		{"Sales Order","SO"},;
>  		{"Repair Order","RO"},;
>  		{"Out Rental","RT"},;
>  		{"In Rental","RI"}}
> 
> 
> Already have the value in mememory for the first element of the 7
> values in the array which is SELF:oDCTRANSCOD:TextValue
> 
> Now I want to save the second element to the table, this is what I am
> doing and is giving me an error:
> 
> 
> 	LOCAL n AS DWORD
> 	n := AScan(aTranscod, SELF:oDCTRANSCOD:TextValue)
> 
> The ascan should return a value
> 
> Then want to save the second element of the value to the Table
> 
> SELF:oDBServer:FIELDPUT(#TRANSCOD, aTranscod[n,2])
> 
> I think I am scanning incorrent the array, the value in memory whic is
> SELF:oDCTRANSCOD:TextValue, can be Purcase Order, Invoice, etc.
> 
> I did this and is giving me a compiled error:
> n := AScan(aTranscod, {|aVal| aVal[2] = SELF:oDCTRANSCOD:TextValue})
> Want to save for Sales Order, "SO" in #TRANSCOD	
> 
> Some help please, thanks
> 
> Jose
> 
>  
> --

[toc] | [prev] | [next] | [standalone]


#10611

FromSherlock <sherlock@sherlock.com.au>
Date2017-05-27 02:37 -0700
Message-ID<5e5c4dd8-5001-4fdf-9e0b-c71e59ffffa5@googlegroups.com>
In reply to#10607
Forgot

server:FIELDPUT(#transcod, aData)

LOCAL uValue AS USUAL 
Local aData AS ARRAY 

UValue := server:FIELDGET(#transcod) 
if isArray(uValue) 
   aData := Uvalue 
endif 

Phil McGuinness
---------------

[toc] | [prev] | [next] | [standalone]


#10612

From"Karl-Heinz" <invalid@invalid.invalid>
Date2017-05-27 12:10 +0200
Message-ID<eot1k5Fd25nU1@mid.individual.net>
In reply to#10611
Hi Phil,

> server:FIELDPUT(#transcod, aData)
>
> LOCAL uValue AS USUAL
> Local aData AS ARRAY
>
> UValue := server:FIELDGET(#transcod)
> if isArray(uValue)
>   aData := Uvalue
> endif

seems i´m on another trip ;-)

i may be wrong, but my interpretation is that Jose wants to save a selected
value e.g. "PO" to the server field #TRANSCOD. So i´m wondering:

1. How are his users currently able to select any of the codes ?
2. why he´s not using a comboBox that saves a corresponding value
automatically, without the need to ascan() anything  ?


fill combobox:

oDCTRANSCOD:Fillusing ( aTranscod )


regards
Karl-Heinz 

[toc] | [prev] | [next] | [standalone]


#10608

FromFranz Rachbauer <office@rachbauer.org>
Date2017-05-27 09:28 +0200
Message-ID<ogb9qd$1cpq$1@gioia.aioe.org>
In reply to#10606
Hi Jose,
which error do you get, maybe the problem is oDCTRANSCOD? This code does 
well:
	LOCAL aTranscod AS ARRAY
	LOCAL n AS DWORD
	
	 aTranscod :={{"Purchase Order","PO"},;
  		{"Invoice","IN"},;
  		{"Return Sales","SR"},;
		{"Sales Order","SO"},;
  		{"Repair Order","RO"},;
  		{"Out Rental","RT"},;
  		{"In Rental","RI"}}

	n := AScan(aTranscod, {|aVal| aVal[1] == "Sales Order"})
	IF n > 0
		? aTranscod[n,1], aTranscod[n,2]
	ENDIF

Regards, Franz


Am 27.05.2017 um 02:20 schrieb Jose F Zouain:
> I did this and is giving me a compiled error:
> n := AScan(aTranscod, {|aVal| aVal[2] = SELF:oDCTRANSCOD:TextValue})

[toc] | [prev] | [next] | [standalone]


#10609

FromSteve <steven_emmett@yahoo.co.uk>
Date2017-05-27 00:36 -0700
Message-ID<62ae64e1-8474-48af-9521-b0ed10811aed@googlegroups.com>
In reply to#10606
On Saturday, May 27, 2017 at 1:20:17 AM UTC+1, Jose F Zouain wrote:
> Hi Guys
> 
> I am still rusty, don't know why is giving me an error.
> 
> Have a multi-dimension array, all elements are string:
> 
>  aTranscod :={{"Purchase Order","PO"},;
>  		{"Invoice","IN"},;
>  		{"Return Sales","SR"},;
> 		{"Sales Order","SO"},;
>  		{"Repair Order","RO"},;
>  		{"Out Rental","RT"},;
>  		{"In Rental","RI"}}
> 
> 
> Already have the value in mememory for the first element of the 7
> values in the array which is SELF:oDCTRANSCOD:TextValue
> 
> Now I want to save the second element to the table, this is what I am
> doing and is giving me an error:
> 
> 
> 	LOCAL n AS DWORD
> 	n := AScan(aTranscod, SELF:oDCTRANSCOD:TextValue)
> 
> The ascan should return a value
> 
> Then want to save the second element of the value to the Table
> 
> SELF:oDBServer:FIELDPUT(#TRANSCOD, aTranscod[n,2])
> 
> I think I am scanning incorrent the array, the value in memory whic is
> SELF:oDCTRANSCOD:TextValue, can be Purcase Order, Invoice, etc.
> 
> I did this and is giving me a compiled error:
> n := AScan(aTranscod, {|aVal| aVal[2] = SELF:oDCTRANSCOD:TextValue})
> Want to save for Sales Order, "SO" in #TRANSCOD	
> 
> Some help please, thanks
> 
> Jose
> 
>  
> --

Hi Jose, 
         I suspect that the scan is returning 0 , in which case are you certain that SELF:oDCTRANSCOD:TextValue in the expression " n := AScan(aTranscod, SELF:oDCTRANSCOD:TextValue) " is the correct text to search for ?

Regards, 
Steve

[toc] | [prev] | [next] | [standalone]


#10610

FromSteve <steven_emmett@yahoo.co.uk>
Date2017-05-27 00:53 -0700
Message-ID<17388e2a-c82a-4d20-bf53-8afffcc994f5@googlegroups.com>
In reply to#10606
On Saturday, May 27, 2017 at 1:20:17 AM UTC+1, Jose F Zouain wrote:
> Hi Guys
> 
> I am still rusty, don't know why is giving me an error.
> 
> Have a multi-dimension array, all elements are string:
> 
>  aTranscod :={{"Purchase Order","PO"},;
>  		{"Invoice","IN"},;
>  		{"Return Sales","SR"},;
> 		{"Sales Order","SO"},;
>  		{"Repair Order","RO"},;
>  		{"Out Rental","RT"},;
>  		{"In Rental","RI"}}
> 
> 
> Already have the value in mememory for the first element of the 7
> values in the array which is SELF:oDCTRANSCOD:TextValue
> 
> Now I want to save the second element to the table, this is what I am
> doing and is giving me an error:
> 
> 
> 	LOCAL n AS DWORD
> 	n := AScan(aTranscod, SELF:oDCTRANSCOD:TextValue)
> 
> The ascan should return a value
> 
> Then want to save the second element of the value to the Table
> 
> SELF:oDBServer:FIELDPUT(#TRANSCOD, aTranscod[n,2])
> 
> I think I am scanning incorrent the array, the value in memory whic is
> SELF:oDCTRANSCOD:TextValue, can be Purcase Order, Invoice, etc.
> 
> I did this and is giving me a compiled error:
> n := AScan(aTranscod, {|aVal| aVal[2] = SELF:oDCTRANSCOD:TextValue})
> Want to save for Sales Order, "SO" in #TRANSCOD	
> 
> Some help please, thanks
> 
> Jose
> 
>  
> --

Hi Jose,
         I've just done some testing and you get a runtime error with this unless you use a codeblock with ascan (maybe because it's a two dimensional array)

So this will work n := ascan(aTranscod,{|aTranscod|aTranscod[1] = SELF:oDCTRANSCOD:TextValue})


When testing, I used a static value to compare, but the code above will use your dynamic value.

Regards,
Steve

[toc] | [prev] | [next] | [standalone]


#10613

From"Jose F Zouain" <jfzouain@zetaconcepts.com>
Date2017-05-28 00:54 +0000
Message-ID<eouldcFoj1jU1@mid.individual.net>
In reply to#10610
Hi Guys

Thanks all for responding.

I am using a combo box with Fillusing, at the screen display is working
good, we load the first element of the array and user selects it.
The problem is saving it to the table.

Already have in memory the element selected, let's say Sales Order.
Now want to save in column "SO", a character(2) column  

Phil
Thanks don't want to use Memo field, is already a character (2) column.

Franz
n := AScan(aTranscod, {|aVal| aVal[1] == "Sales Order"})
This code is working, no compling error
Returns n==0
So when saving it crashes


Steve
This search I did is incorrect 
n := AScan(aTranscod, SELF:oDCTRANSCOD:TextValue)
Have to search for first element in the array and save the correspoding
2nd element.

Steve
When I compile this, gives me an error:  Bad function call 51138
n := ascan(aTranscod,{|aTranscod|aTranscod[1] =
SELF:oDCTRANSCOD:TextValue})

I just replaced = SELF:oDCTRANSCOD:TextValue}) with = Sales Order})
and it worked because I selected Sales Order from the Combo Box.
Now I know where the problem is at SELF:oDCTRANSCOD:TextValue

But when I displayed it at the screen is correct:
SELF:oDCTRANSCOD:TextValue == "Sales Order"

Johan
Thanks, but I have the same error as above -> Bad function call 51138
But for testing it will not crash, because of this:
IF n > 0
  SELF:oDBServer:FIELDPUT(#TRANSCOD, aTranscod[n,2])
ENDIF
=============================

I just did a workaround don't know if is correct, but is working now
replaced the SELF:oDCTRANSCOD:TextValue like this

LOCAL sValue AS STRING
sValue := SELF:oDCTRANSCOD:TextValue
n := AScan(aTranscod,{|aTranscod|aTranscod[1] == sValue})

and is saving it OK, looks like the ascan doesn't like to compare with
SLE value

Thanks all for your help, this why I have not left VO, because of the
help you all guys provides here.

Please let  me know if this OK, what I did.

Best regards

Jose
-- 

[toc] | [prev] | [next] | [standalone]


#10614

FromJohnMartens <martens@tennishulp.info>
Date2017-05-28 08:31 +0200
Message-ID<ogdql1$u6k$1@dont-email.me>
In reply to#10613
When using a 2 dim array to fill the combo see the difference between
SELF:oDCTRANSCOD:TextValue
SELF:oDCTRANSCOD:Value

John


Op 28-5-2017 om 02:54 schreef Jose F Zouain:
> Hi Guys
> 
> Thanks all for responding.
> 
> I am using a combo box with Fillusing, at the screen display is working
> good, we load the first element of the array and user selects it.
> The problem is saving it to the table.
> 
> Already have in memory the element selected, let's say Sales Order.
> Now want to save in column "SO", a character(2) column
> 
> Phil
> Thanks don't want to use Memo field, is already a character (2) column.
> 
> Franz
> n := AScan(aTranscod, {|aVal| aVal[1] == "Sales Order"})
> This code is working, no compling error
> Returns n==0
> So when saving it crashes
> 
> 
> Steve
> This search I did is incorrect
> n := AScan(aTranscod, SELF:oDCTRANSCOD:TextValue)
> Have to search for first element in the array and save the correspoding
> 2nd element.
> 
> Steve
> When I compile this, gives me an error:  Bad function call 51138
> n := ascan(aTranscod,{|aTranscod|aTranscod[1] =
> SELF:oDCTRANSCOD:TextValue})
> 
> I just replaced = SELF:oDCTRANSCOD:TextValue}) with = Sales Order})
> and it worked because I selected Sales Order from the Combo Box.
> Now I know where the problem is at SELF:oDCTRANSCOD:TextValue
> 
> But when I displayed it at the screen is correct:
> SELF:oDCTRANSCOD:TextValue == "Sales Order"
> 
> Johan
> Thanks, but I have the same error as above -> Bad function call 51138
> But for testing it will not crash, because of this:
> IF n > 0
>    SELF:oDBServer:FIELDPUT(#TRANSCOD, aTranscod[n,2])
> ENDIF
> =============================
> 
> I just did a workaround don't know if is correct, but is working now
> replaced the SELF:oDCTRANSCOD:TextValue like this
> 
> LOCAL sValue AS STRING
> sValue := SELF:oDCTRANSCOD:TextValue
> n := AScan(aTranscod,{|aTranscod|aTranscod[1] == sValue})
> 
> and is saving it OK, looks like the ascan doesn't like to compare with
> SLE value
> 
> Thanks all for your help, this why I have not left VO, because of the
> help you all guys provides here.
> 
> Please let  me know if this OK, what I did.
> 
> Best regards
> 
> Jose
> 

[toc] | [prev] | [next] | [standalone]


#10621

FromMathias <mathias.hakansson@consultec.se>
Date2017-05-30 00:28 -0700
Message-ID<939e7c4c-ee70-4bb0-ac4f-d3f0dc62a56e@googlegroups.com>
In reply to#10613
Hi Jose,

you should do 

textVal := SELF:oDCTRANSCOD:TextValue
n := ascan(aTranscod,{|aVal| aVal[1] = textVal})

You cannot use self in codeblocks. You should also consider using == instead of =.

? "Larger" = "Large"                        // TRUE
? "Larger" == "Large"                       // FALSE

/Mathias

Den söndag 28 maj 2017 kl. 02:54:06 UTC+2 skrev Jose F Zouain:
> Hi Guys
> 
> Thanks all for responding.
> 
> I am using a combo box with Fillusing, at the screen display is working
> good, we load the first element of the array and user selects it.
> The problem is saving it to the table.
> 
> Already have in memory the element selected, let's say Sales Order.
> Now want to save in column "SO", a character(2) column  
> 
> Phil
> Thanks don't want to use Memo field, is already a character (2) column.
> 
> Franz
> n := AScan(aTranscod, {|aVal| aVal[1] == "Sales Order"})
> This code is working, no compling error
> Returns n==0
> So when saving it crashes
> 
> 
> Steve
> This search I did is incorrect 
> n := AScan(aTranscod, SELF:oDCTRANSCOD:TextValue)
> Have to search for first element in the array and save the correspoding
> 2nd element.
> 
> Steve
> When I compile this, gives me an error:  Bad function call 51138
> n := ascan(aTranscod,{|aTranscod|aTranscod[1] =
> SELF:oDCTRANSCOD:TextValue})
> 
> I just replaced = SELF:oDCTRANSCOD:TextValue}) with = Sales Order})
> and it worked because I selected Sales Order from the Combo Box.
> Now I know where the problem is at SELF:oDCTRANSCOD:TextValue
> 
> But when I displayed it at the screen is correct:
> SELF:oDCTRANSCOD:TextValue == "Sales Order"
> 
> Johan
> Thanks, but I have the same error as above -> Bad function call 51138
> But for testing it will not crash, because of this:
> IF n > 0
>   SELF:oDBServer:FIELDPUT(#TRANSCOD, aTranscod[n,2])
> ENDIF
> =============================
> 
> I just did a workaround don't know if is correct, but is working now
> replaced the SELF:oDCTRANSCOD:TextValue like this
> 
> LOCAL sValue AS STRING
> sValue := SELF:oDCTRANSCOD:TextValue
> n := AScan(aTranscod,{|aTranscod|aTranscod[1] == sValue})
> 
> and is saving it OK, looks like the ascan doesn't like to compare with
> SLE value
> 
> Thanks all for your help, this why I have not left VO, because of the
> help you all guys provides here.
> 
> Please let  me know if this OK, what I did.
> 
> Best regards
> 
> Jose
> --

[toc] | [prev] | [next] | [standalone]


#10623

From"Jose F Zouain" <jfzouain@zetaconcepts.com>
Date2017-05-31 11:42 +0000
Message-ID<ep7oh8Fs3lbU1@mid.individual.net>
In reply to#10621
Mathias wrote:

> Hi Jose,
> 
> you should do 
> 
> textVal := SELF:oDCTRANSCOD:TextValue
> n := ascan(aTranscod,{|aVal| aVal[1] = textVal})
> 
> You cannot use self in codeblocks. You should also consider using ==
> instead of =.
> 
> ? "Larger" = "Large"                        // TRUE
> ? "Larger" == "Large"                       // FALSE
> 
> /Mathias
> 

Hi Mathias and all in the group

What you just posted is what I did, thanks.

I can consider this closed.

Best regards to all

Jose Zouain

[toc] | [prev] | [next] | [standalone]


#10615 — Re: Help on saving an array element to table [OT]

From"Karl-Heinz" <invalid@invalid.invalid>
Date2017-05-28 09:59 +0200
SubjectRe: Help on saving an array element to table [OT]
Message-ID<eovebfFtn7lU1@mid.individual.net>
In reply to#10606
Hi Johan,

i hope you liked the annual Italian show the same as i did. The final
countdown today will bring this endresult <g>

1. Dumoulin
2. Nibali
3. Pinot
4. Quintana
5. Zakarin

although it´s possible that Pinot eats Nibali too ;-)

BTW. a pity that Landa and Thomas were early out of the race ...

regards
Karl-Heinz 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web