Log in

View Full Version : Programming 101...............


sarettah
10-23-2003, 09:41 AM
What is the logical output from this code snippet....... (language is VFP but should be fairly discernible to anyone who has read code before.....)

procedure brandon
parameter username, password
clear
if empty(username)
username='opranaut'
endif
if empty(password)
password='intelligent'
endif

sqlport=sqlconnect('brandon',usernam,password)

sql_str='select * from brandon_master order by value'
&sql_str

*********************************************

clue:

brandon_master looks like this:

Property value
-------------------
age ???
shoesize ???
iq ???



Last edited by sarettah at Oct 23 2003, 08:58 AM

HoneyBlond
10-23-2003, 10:06 AM
Originally posted by sarettah@Oct 24 2003, 12:49 AM
What is the logical output from this code snippet....... (language is VFP but should be fairly discernible to anyone who has read code before.....)

procedure brandon
parameter username, password
clear
if empty(username)
username='opranaut'
endif
if empty(password)
password='intelligent'
endif

sqlport=sqlconnect('brandon',usernam,password)

sql_str='select * from brandon_master order by value'
&sql_str

*********************************************

clue:

brandon_master looks like this:

Property value
-------------------
age ???
shoesize ???
iq ???

ERROR: UNKNOWN IQ EXCEPTION(80000602).

Mr Benn
10-23-2003, 11:45 AM
Originally posted by sarettah@Oct 23 2003, 05:49 AM
What is the logical output from this code snippet....... (language is VFP but should be fairly discernible to anyone who has read code before.....)
...

sqlport=sqlconnect('brandon',usernam,password)

sql_str='select * from brandon_master order by value'
&sql_str

No output, because you didn't send your SQL query to some function like sqlquery() ;)

Or was the "&sql_str" meant to imply it was executing a query with that string?

sarettah
10-23-2003, 12:59 PM
Originally posted by Mr Benn+Oct 23 2003, 10:53 AM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (Mr Benn @ Oct 23 2003, 10:53 AM)</td></tr><tr><td id='QUOTE'><!--QuoteBegin--sarettah@Oct 23 2003, 05:49 AM
What is the logical output from this code snippet....... (language is VFP but should be fairly discernible to anyone who has read code before.....)
...

sqlport=sqlconnect('brandon',usernam,password)

sql_str='select * from brandon_master order by value'
&sql_str

No output, because you didn't send your SQL query to some function like sqlquery() ;)

Or was the "&sql_str" meant to imply it was executing a query with that string?[/b][/quote]
lololol............

damn you are good.............

in vfp the '&' means evaluate... So if it had been a local table then it would have executed....

since the whole sqlconnect( was to open a remote table (sqlserver or oracle), I indicated that it was a remote db I was calling from...

So you are right... absolutely nothing would conme out except an error message abou the table not existing :)

so lessee...

we would have to add something like:

=sqlexec(sqlport,sql_str,'Temptable')

to actually get our return....


:yowsa:


It was a dumb joke anyway that got worse when my original entry got screwed up when I hit a [tab] and then an [enter] so the post was only a quarter complete....


:blink:

Carrie
10-23-2003, 01:17 PM
The query would be returned as an array, so unless you're wanting the error code for trying to display an array you'll need to split that sucker up and then print it. :)

But I would suspect a return ordered by value would be Brand0n's age > shoesize > IQ.

edit: had to make that clearer



Last edited by Carrie at Oct 23 2003, 12:27 PM

Trev
10-23-2003, 01:22 PM
LOST!!!!

:blink: :huh: :unsure: :wacko:

sarettah
10-23-2003, 01:27 PM
Originally posted by Carrie@Oct 23 2003, 12:25 PM
The query would be returned as an array, so unless you're wanting the error code for trying to display an array you'll need to split that sucker up and then print it. :)

But I would suspect a return ordered by value would be Brand0n's age > shoesize > IQ.

edit: had to make that clearer
nopers

=sqlexec(sqlport,sql_str,'Temptable')

returns a cursor called temptable :)

that is the vfp sql execution routine.....

and you return results are obviously in descending order

actual return would be iq, shoesize, then age.........

it would default to ascending

:yowsa:

sarettah
10-23-2003, 01:28 PM
Originally posted by Trev@Oct 23 2003, 12:30 PM
LOST!!!!

:blink: :huh: :unsure: :wacko:
Sorry bout that trev...........

here, try this one:



endwith

return

Carrie
10-23-2003, 01:35 PM
I'm surprised the board didn't smack you for having a post that long!

You're right, my results are DESC and you didn't specify an ORDER BY, but you know darn well I'm a phper and in that language, you'd get an array error. ;)
(Unless you previously specified a dbquery function that would do key->value splits, methinks.)

Bah. Either way you work it, his age has a higher value than his IQ, and being that he was born in '74, that doesn't bode well for him! :nyanya:



Last edited by Carrie at Oct 23 2003, 12:43 PM

voodooman
10-23-2003, 01:42 PM
sarettaH,

No offense, but that whole thing looks just like
one of brand0n's posts.

:P



Last edited by voodooman at Oct 23 2003, 11:54 AM

Trev
10-23-2003, 01:44 PM
I was going to quote you Sarettah but that would have made this the longest thread ever with the fewest posts :D

I'm guessing something to do with times/dates and mail?

Trev
10-23-2003, 01:45 PM
Originally posted by voodooman@Oct 23 2003, 07:50 PM
sarettaH,

No offense, but that whole thing looks just like
on or brand0n's posts.

:P
Hahahahah :okthumb:

That a damn good one :wnw:

eatapeach
10-23-2003, 03:12 PM
my cat's breath smells like cat food.

Winetalk.com
10-23-2003, 03:21 PM
Originally posted by Carrie@Oct 23 2003, 12:43 PM
I'm surprised the board didn't smack you for having a post that long!


I just did
;-)))

brand0n
10-23-2003, 03:25 PM
10 ? "fuckyou"
20 goto 10


an "end" statement isnt needed due to the loop

eatapeach
10-23-2003, 03:32 PM
Originally posted by brand0n@Oct 23 2003, 11:33 AM
10 ? "fuckyou"
20 goto 10


an "end" statement isnt needed due to the loop
ha, that brings back old memories.

every time i'd go into a store that had a TI computer i'd type that in and then go find the toy department to look for star wars stuff.

sarettah
10-23-2003, 03:48 PM
Originally posted by voodooman@Oct 23 2003, 12:50 PM
sarettaH,

No offense, but that whole thing looks just like
one of brand0n's posts.

:P
Yeah, but it makes a whole lot more sense than his posts.........






:yowsa:

Mr Benn
10-24-2003, 07:48 AM
Originally posted by brand0n@Oct 23 2003, 11:33 AM
10 ? "fuckyou"
20 goto 10


an "end" statement isnt needed due to the loop
The ABC's of Russian coding on the Spectrum ;)

10 print "I sale good code"
20 goto 10
30 run

;)

brand0n
10-24-2003, 10:15 AM
Originally posted by Mr Benn+Oct 24 2003, 03:56 AM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (Mr Benn @ Oct 24 2003, 03:56 AM)</td></tr><tr><td id='QUOTE'><!--QuoteBegin--brand0n@Oct 23 2003, 11:33 AM
10 ? "fuckyou"
20 goto 10


an "end" statement isnt needed due to the loop
The ABC's of Russian coding on the Spectrum ;)

10 print "I sale good code"
20 goto 10
30 run

;)[/b][/quote]
that code wouldnt work, 30 run would never be seen do to the loop 20 makes, and to save you some time print = "?"

Mr Benn
10-24-2003, 11:01 AM
Originally posted by brand0n@Oct 24 2003, 06:23 AM

that code wouldnt work, 30 run would never be seen do to the loop 20 makes, and to save you some time print = "?"
In Spectrum +3 Basic it would work. And the "?" substitution for print, would not. I did say it was for the Spectrum.

Trev
10-24-2003, 12:16 PM
Originally posted by Mr Benn+Oct 24 2003, 05:09 PM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (Mr Benn @ Oct 24 2003, 05:09 PM)</td></tr><tr><td id='QUOTE'><!--QuoteBegin--brand0n@Oct 24 2003, 06:23 AM

that code wouldnt work, 30 run would never be seen do to the loop 20 makes, and to save you some time print = "?"
In Spectrum +3 Basic it would work. And the "?" substitution for print, would not. I did say it was for the Spectrum.[/b][/quote]
Ahh the ZX Spectrum 48k my first love :inlove:


:okthumb:

sarettah
10-24-2003, 12:23 PM
GOTO s ????

:barfon: :barfon: :barfon: :barfon:

Trev
10-24-2003, 12:32 PM
Originally posted by sarettah@Oct 24 2003, 06:31 PM
GOTO s ????

:barfon: :barfon: :barfon: :barfon:
Now now now... we all had to start somewhere :biglaugh:

Dravyk
10-25-2003, 03:30 PM
Geekiest Thread on Oprano Award!! :nyanya:

Carrie
10-25-2003, 03:37 PM
Originally posted by brand0n@Oct 23 2003, 02:33 PM
10 ? "fuckyou"
20 goto 10


an "end" statement isnt needed due to the loop
These were the best and cheapest custom screen savers ever.

brand0n
10-26-2003, 08:03 AM
Originally posted by Carrie+Oct 25 2003, 11:45 AM--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (Carrie @ Oct 25 2003, 11:45 AM)</td></tr><tr><td id='QUOTE'><!--QuoteBegin--brand0n@Oct 23 2003, 02:33 PM
10 ? "fuckyou"
20 goto 10


an "end" statement isnt needed due to the loop
These were the best and cheapest custom screen savers ever.[/b][/quote]
ahh you like that do ya?

so does this mean we should kiss n make up?