
-----------------------------------
aldreneo
Tue May 02, 2006 6:45 pm

Put and get on the same line...
-----------------------------------
How can I make it do this

var age:string
put "How old are you" + get age

So that they are outputted on the same line?

-----------------------------------
Cervantes
Tue May 02, 2006 6:51 pm


-----------------------------------
Judging by the title, I got excited and thought someone was asking how to use "get" as a function, rather than a cruddy keyword, so you can do things like
put get
or
name = get

Well, to answer your question, you need to add a .. after the put line:
var age : string
put "How old are you? " ..
get age


-----------------------------------
TokenHerbz
Tue May 02, 2006 6:58 pm


-----------------------------------
aha, unless me means to use the put and get on the same line in the CODE

which i dont do but...  


put "Get text: " .. get text


-----------------------------------
TokenHerbz
Tue May 02, 2006 7:03 pm


-----------------------------------
you can make lines of code on a line, but i dont reccomend doing this at all, because its sloppy, and confusing:

Bad way:

var text: string put "Get text: " .. get text put text

Better way:

var text: string

put "get text:" ..    %%these two ..'s allow the line to be joined by other things
get text

put text


ex: of joining output to make it one line on screen, like cervantes said..


put "Part 1 " ..
put "Part 2 " ..
put "Part 3"


-----------------------------------
Clayton
Tue May 02, 2006 8:43 pm


-----------------------------------
out of curiosity Cervantes, what do you mean using get as a function, i didnt think that was possible....

-----------------------------------
do_pete
Tue May 02, 2006 8:56 pm


-----------------------------------
It's not possible.

-----------------------------------
[Gandalf]
Tue May 02, 2006 9:09 pm


-----------------------------------
It's not possible.
Why not?
fcn get_s : string 
    var str : string
    get str :*
    result str
end get_s

put get_s

-----------------------------------
Clayton
Tue May 02, 2006 9:33 pm


-----------------------------------
but why would you do that, i mean, what is the purpose of such a fcn?

-----------------------------------
do_pete
Tue May 02, 2006 9:45 pm


-----------------------------------
"]It's not possible.
Why not?
fcn get_s : string 
    var str : string
    get str :*
    result str
end get_s

put get_sNo, I meant get can't be used like this:a := get

-----------------------------------
[Gandalf]
Tue May 02, 2006 10:37 pm


-----------------------------------
No, I meant get can't be used like this:a := get
fcn get_s : string
    var str : string
    get str :*
    result str
end get_s

var a : string
a := get_s
 :?

-----------------------------------
do_pete
Tue May 02, 2006 10:42 pm


-----------------------------------
No I mean the get you use in this:get acannot be used like this:a := get

-----------------------------------
[Gandalf]
Tue May 02, 2006 10:48 pm


-----------------------------------
Ah, I see.  Well, yeah, that's because get is created that way internally.  That doesn't stop you from simulating a get() function, as I believe Cervantes was trying to say.

-----------------------------------
upthescale
Wed May 03, 2006 5:11 pm


-----------------------------------
locate is an option to...


put"What is your name?"

locate(1,20)
get name

-----------------------------------
do_pete
Wed May 03, 2006 5:26 pm


-----------------------------------
Or you could just do it Cervantes' way since it's much easier.

-----------------------------------
Cervantes
Sat May 06, 2006 1:03 pm


-----------------------------------
Gandalf's got it. That's what I was geting at

do_pete, you're not seeing the power of using a gets type call as a function.

Say I was doing Martin's 
function is_valid_roman_numeral (s : string) : boolean
    % Compute!
end is_valid_roman_numeral

Now, how would I call it? Using get as a keyword, I have no choice but to use a temporary variable that really doesn't serve any purpose whatsoever:

var temp : string
get temp
put is_valid_roman_numeral (temp)

However, if I use a get as a function (like Gandalf has done), then I don't have to create a useless variable, and I can shrink the program call to one line:

put is_valid_roman_numeral (get)

Much nicer, yes?

-----------------------------------
NikG
Sun May 07, 2006 8:53 pm


-----------------------------------
"]fcn get_s : string
    var str : string
    get str :*
    result str
end get_s

var a : string
a := get_s
However, if I use a get as a function (like Gandalf has done), then I don't have to create a useless variable, and I can shrink the program call to one line: put is_valid_roman_numeral (get) 
How exactly are you avoiding creating a "useless" variable?  Gandalf's function still has to create a temp var (str) to get the input.

-----------------------------------
[Gandalf]
Sun May 07, 2006 9:37 pm


-----------------------------------
Yes, which is a limitation of you creating the function in a language which doesn't allow for it beforehand.  

The difference is that you are not creating the variable in your actual code, but inside the scope of the function.  It allows for more flexible and simple code than if you had used the get keyword as is demonstrated by code such as:
put is_valid_roman_numeral (get)
